Projektarbeit-MYP/backend/docker-compose.backend.yml

178 lines
4.4 KiB
YAML

# 🏭 MYP Backend - Standalone Server Konfiguration
# Backend-Service als vollständig unabhängiger Server
version: '3.8'
services:
# === BACKEND SERVICE ===
backend:
build:
context: .
dockerfile: Dockerfile
args:
- BUILDKIT_INLINE_CACHE=1
image: myp/backend:latest
container_name: myp-backend-standalone
restart: unless-stopped
environment:
# Flask-Konfiguration
- FLASK_APP=app.py
- FLASK_ENV=${FLASK_ENV:-production}
- PYTHONUNBUFFERED=1
# Datenbank
- DATABASE_PATH=${DATABASE_PATH:-instance/myp.db}
# Sicherheit
- SECRET_KEY=${SECRET_KEY:-7445630171969DFAC92C53CEC92E67A9CB2E00B3CB2F}
- JWT_SECRET=${JWT_SECRET:-secure-jwt-secret}
# CORS-Konfiguration für Frontend-Zugriff
- CORS_ORIGINS=${CORS_ORIGINS:-http://localhost:3000,https://frontend.myp.local}
# Drucker-Konfiguration
- "PRINTERS=${PRINTERS:-{\"Drucker 1\": {\"ip\": \"192.168.0.100\"}, \"Drucker 2\": {\"ip\": \"192.168.0.101\"}, \"Drucker 3\": {\"ip\": \"192.168.0.102\"}, \"Drucker 4\": {\"ip\": \"192.168.0.103\"}, \"Drucker 5\": {\"ip\": \"192.168.0.104\"}, \"Drucker 6\": {\"ip\": \"192.168.0.106\"}}}"
# TAPO Smart Plug
- TAPO_USERNAME=${TAPO_USERNAME:-till.tomczak@mercedes-benz.com}
- TAPO_PASSWORD=${TAPO_PASSWORD:-744563017196A}
# Netzwerk
- HOST=0.0.0.0
- PORT=5000
# Logging
- LOG_LEVEL=${LOG_LEVEL:-INFO}
volumes:
- backend_instance:/app/instance
- backend_logs:/app/logs
- backend_migrations:/app/migrations
- ./config:/app/config:ro
ports:
- "5000:5000" # Direkter Port-Zugang für Backend-Server
networks:
- backend-network
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:5000/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
labels:
- "service.type=backend"
- "service.name=myp-backend"
- "service.environment=${FLASK_ENV:-production}"
# === BACKEND DATENBANK (Optional: Separate PostgreSQL) ===
backend-db:
image: postgres:15-alpine
container_name: myp-backend-db
restart: unless-stopped
environment:
- POSTGRES_DB=${DB_NAME:-myp_backend}
- POSTGRES_USER=${DB_USER:-myp_user}
- POSTGRES_PASSWORD=${DB_PASSWORD:-secure_password}
- POSTGRES_HOST_AUTH_METHOD=trust
volumes:
- backend_db_data:/var/lib/postgresql/data
- ./sql/init:/docker-entrypoint-initdb.d:ro
ports:
- "5432:5432"
networks:
- backend-network
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${DB_USER:-myp_user} -d ${DB_NAME:-myp_backend}"]
interval: 10s
timeout: 5s
retries: 5
# === BACKEND CACHE (Redis) ===
backend-cache:
image: redis:7.2-alpine
container_name: myp-backend-cache
restart: unless-stopped
command: redis-server --appendonly yes --requirepass ${REDIS_PASSWORD:-backend_cache_password}
volumes:
- backend_cache_data:/data
ports:
- "6379:6379"
networks:
- backend-network
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 3
# === PERSISTENTE VOLUMES ===
volumes:
backend_instance:
driver: local
driver_opts:
type: none
o: bind
device: ./instance
backend_logs:
driver: local
driver_opts:
type: none
o: bind
device: ./logs
backend_migrations:
driver: local
driver_opts:
type: none
o: bind
device: ./migrations
backend_db_data:
driver: local
backend_cache_data:
driver: local
# === BACKEND-NETZWERK ===
networks:
backend-network:
driver: bridge
driver_opts:
com.docker.network.enable_ipv6: "false"
com.docker.network.bridge.enable_ip_masquerade: "true"
labels:
- "description=MYP Backend Server Netzwerk"
- "project=myp-backend"
- "tier=backend"
# === KONFIGURATION FÜR BACKEND ===
x-backend-defaults: &backend-defaults
restart: unless-stopped
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
labels: "service,environment,tier"
x-healthcheck-backend: &backend-healthcheck
interval: 30s
timeout: 10s
retries: 3
start_period: 40s