99 lines
2.2 KiB
YAML
99 lines
2.2 KiB
YAML
services:
|
|
# PostgreSQL 数据库
|
|
db:
|
|
image: postgres:15-alpine
|
|
container_name: meijiaka-db
|
|
environment:
|
|
POSTGRES_USER: postgres
|
|
POSTGRES_PASSWORD: postgres
|
|
POSTGRES_DB: meijiaka
|
|
volumes:
|
|
- postgres_data:/var/lib/postgresql/data
|
|
ports:
|
|
- "5432:5432"
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U postgres"]
|
|
interval: 5s
|
|
timeout: 5s
|
|
retries: 5
|
|
networks:
|
|
- meijiaka-network
|
|
|
|
# Redis 缓存
|
|
redis:
|
|
image: redis:7-alpine
|
|
container_name: meijiaka-redis
|
|
volumes:
|
|
- redis_data:/data
|
|
ports:
|
|
- "6379:6379"
|
|
healthcheck:
|
|
test: ["CMD", "redis-cli", "ping"]
|
|
interval: 5s
|
|
timeout: 5s
|
|
retries: 5
|
|
networks:
|
|
- meijiaka-network
|
|
|
|
# FastAPI 应用(开发模式)
|
|
api:
|
|
build:
|
|
context: .
|
|
dockerfile: Dockerfile
|
|
container_name: meijiaka-api
|
|
environment:
|
|
- ENV=development
|
|
- DEBUG=true
|
|
- DATABASE_URL=postgresql+asyncpg://postgres:postgres@db:5432/meijiaka
|
|
- REDIS_HOST=redis
|
|
- REDIS_PORT=6379
|
|
- REDIS_DB=0
|
|
- SECRET_KEY=dev-secret-key-change-in-production
|
|
volumes:
|
|
- .:/app
|
|
- ~/Documents/Meijiaka:/root/Documents/Meijiaka
|
|
ports:
|
|
- "8080:8000"
|
|
depends_on:
|
|
db:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
command: uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload
|
|
networks:
|
|
- meijiaka-network
|
|
|
|
# Async Engine Scheduler: 统一调度所有第三方异步任务
|
|
scheduler:
|
|
build:
|
|
context: .
|
|
dockerfile: Dockerfile
|
|
container_name: meijiaka-scheduler
|
|
environment:
|
|
- ENV=development
|
|
- DEBUG=true
|
|
- DATABASE_URL=postgresql+asyncpg://postgres:postgres@db:5432/meijiaka
|
|
- REDIS_HOST=redis
|
|
- REDIS_PORT=6379
|
|
- REDIS_DB=0
|
|
- SECRET_KEY=dev-secret-key-change-in-production
|
|
volumes:
|
|
- .:/app
|
|
- ~/Documents/Meijiaka:/root/Documents/Meijiaka
|
|
depends_on:
|
|
db:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
command: python -m app.scheduler.main
|
|
networks:
|
|
- meijiaka-network
|
|
|
|
volumes:
|
|
postgres_data:
|
|
redis_data:
|
|
|
|
networks:
|
|
meijiaka-network:
|
|
driver: bridge
|