services: # Nginx Reverse Proxy nginx: image: nginx:alpine container_name: lottery-nginx ports: - "80:80" - "443:443" volumes: - ./nginx.conf:/etc/nginx/nginx.conf:ro - ./ssl:/etc/nginx/ssl:ro depends_on: - backend - frontend restart: always networks: - lottery-network # Flask Backend backend: build: context: . dockerfile: Dockerfile.backend container_name: lottery-backend expose: - "5000" env_file: - .env environment: - FLASK_ENV=production - FLASK_DEBUG=false - PYTHONUNBUFFERED=1 restart: always networks: - lottery-network healthcheck: test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:5000/api/health')"] interval: 30s timeout: 10s retries: 3 start_period: 40s deploy: resources: limits: cpus: "1" memory: 2G reservations: cpus: "0.5" memory: 1G # Next.js Frontend frontend: build: context: . dockerfile: Dockerfile.frontend args: NEXT_PUBLIC_API_URL: /api container_name: lottery-frontend expose: - "3000" environment: - NEXT_PUBLIC_API_URL=/api - NODE_ENV=production depends_on: - backend restart: always networks: - lottery-network deploy: resources: limits: cpus: "0.5" memory: 512M reservations: cpus: "0.25" memory: 256M networks: lottery-network: driver: bridge