version: '3.8' services: # PostgreSQL 数据库 postgres: image: postgres:16-alpine container_name: miaosi-postgres environment: POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres POSTGRES_DB: miaosi ports: - "5432:5432" volumes: - postgres_data:/var/lib/postgresql/data healthcheck: test: ["CMD-SHELL", "pg_isready -U postgres"] interval: 5s timeout: 5s retries: 5 # Redis 缓存/消息队列 redis: image: redis:7-alpine container_name: miaosi-redis ports: - "6379:6379" volumes: - redis_data:/data healthcheck: test: ["CMD", "redis-cli", "ping"] interval: 5s timeout: 5s retries: 5 # FastAPI 后端服务 api: build: context: . dockerfile: Dockerfile container_name: miaosi-api ports: - "8000:8000" environment: DATABASE_URL: postgresql+asyncpg://postgres:postgres@postgres:5432/miaosi REDIS_URL: redis://redis:6379/0 DEBUG: "true" depends_on: postgres: condition: service_healthy redis: condition: service_healthy volumes: - ./app:/app/app - video_temp:/tmp/videos command: uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload # Celery Worker celery-worker: build: context: . dockerfile: Dockerfile container_name: miaosi-celery-worker environment: DATABASE_URL: postgresql+asyncpg://postgres:postgres@postgres:5432/miaosi REDIS_URL: redis://redis:6379/0 depends_on: postgres: condition: service_healthy redis: condition: service_healthy volumes: - ./app:/app/app - video_temp:/tmp/videos command: celery -A app.celery_app worker -l info -Q default,review -c 2 # Celery Beat (定时任务调度器) celery-beat: build: context: . dockerfile: Dockerfile container_name: miaosi-celery-beat environment: DATABASE_URL: postgresql+asyncpg://postgres:postgres@postgres:5432/miaosi REDIS_URL: redis://redis:6379/0 depends_on: - celery-worker volumes: - ./app:/app/app command: celery -A app.celery_app beat -l info volumes: postgres_data: redis_data: video_temp: