networks: app-network: driver: bridge services: redis: image: redis:7-alpine restart: unless-stopped networks: - app-network ports: - "6379:6379" healthcheck: test: ["CMD", "redis-cli", "ping"] interval: 5s timeout: 3s retries: 5 deploy: resources: limits: cpus: '0.5' memory: 256M api: build: context: ./api dockerfile: Dockerfile restart: unless-stopped networks: - app-network environment: - REDIS_HOST=${REDIS_HOST:-redis} - REDIS_PORT=${REDIS_PORT:-6379} depends_on: redis: condition: service_healthy ports: - "8000:8000" healthcheck: test: ["CMD", "python", "-c", "import requests; requests.get('http://localhost:8000/health', timeout=2)"] interval: 10s timeout: 5s retries: 3 start_period: 15s deploy: resources: limits: cpus: '1.0' memory: 512M worker: build: context: ./worker dockerfile: Dockerfile restart: unless-stopped networks: - app-network environment: - REDIS_HOST=${REDIS_HOST:-redis} - REDIS_PORT=${REDIS_PORT:-6379} depends_on: redis: condition: service_healthy deploy: resources: limits: cpus: '0.5' memory: 256M frontend: build: context: ./frontend dockerfile: Dockerfile restart: unless-stopped ports: - "${FRONTEND_PORT:-3000}:3000" networks: - app-network environment: - API_URL=${API_URL:-http://api:8000} - NODE_ENV=${NODE_ENV:-production} depends_on: api: condition: service_healthy healthcheck: test: ["CMD", "node", "-e", "const h=require('http');h.get({host:'127.0.0.1',port:3000,path:'/health'},r=>{process.exit(r.statusCode===200?0:1)}).on('error',()=>process.exit(1))"] interval: 10s timeout: 5s retries: 3 start_period: 20s deploy: resources: limits: cpus: '0.5' memory: 512M