version: '3.8' services: postgres: image: postgres:15 container_name: flash_postgres environment: POSTGRES_USER: flash_user POSTGRES_PASSWORD: flash_pass POSTGRES_DB: flash_sale ports: - "5432:5432" volumes: - postgres_data:/var/lib/postgresql/data healthcheck: test: ["CMD-SHELL", "pg_isready -U flash_user -d flash_sale"] interval: 5s timeout: 5s retries: 5 redis: image: redis:alpine container_name: flash_redis ports: - "6379:6379" healthcheck: test: ["CMD", "redis-cli", "ping"] interval: 5s timeout: 5s retries: 5 api: build: . command: ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000", "--workers", "4"] deploy: replicas: 3 depends_on: postgres: condition: service_healthy redis: condition: service_healthy environment: - DATABASE_URL=postgresql+asyncpg://flash_user:flash_pass@postgres:5432/flash_sale - REDIS_HOST=redis - REDIS_PORT=6379 - PYTHONPATH=/app volumes: - .:/app nginx: image: nginx:alpine ports: - "80:80" volumes: - ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro depends_on: - api volumes: postgres_data: