99 lines
2.7 KiB
YAML
99 lines
2.7 KiB
YAML
services:
|
|
postgres:
|
|
image: postgres:16-alpine
|
|
container_name: loom-postgres
|
|
restart: unless-stopped
|
|
environment:
|
|
POSTGRES_USER: ${POSTGRES_USER:-loom}
|
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-loom}
|
|
POSTGRES_DB: ${POSTGRES_DB:-loom}
|
|
volumes:
|
|
- postgres_data:/var/lib/postgresql/data
|
|
ports:
|
|
- "5432:5432"
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-loom} -d ${POSTGRES_DB:-loom}"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
|
|
redis:
|
|
image: redis:7-alpine
|
|
container_name: loom-redis
|
|
restart: unless-stopped
|
|
command: ["redis-server", "--appendonly", "yes"]
|
|
volumes:
|
|
- redis_data:/data
|
|
ports:
|
|
- "6379:6379"
|
|
healthcheck:
|
|
test: ["CMD", "redis-cli", "ping"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
|
|
backend:
|
|
build:
|
|
context: ./backend
|
|
dockerfile: docker/Dockerfile
|
|
container_name: loom-backend
|
|
restart: unless-stopped
|
|
env_file: .env
|
|
environment:
|
|
# 容器网络内的服务名覆盖
|
|
DATABASE_URL: postgresql+asyncpg://${POSTGRES_USER:-loom}:${POSTGRES_PASSWORD:-loom}@postgres:5432/${POSTGRES_DB:-loom}
|
|
REDIS_URL: redis://redis:6379/0
|
|
CELERY_BROKER_URL: redis://redis:6379/1
|
|
CELERY_RESULT_BACKEND: redis://redis:6379/2
|
|
# 允许从前端容器 + ai.aidfxn.com 访问
|
|
CORS_ALLOW_ORIGINS: ${CORS_ALLOW_ORIGINS:-http://localhost,http://frontend,https://ai.aidfxn.com}
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
ports:
|
|
- "8000:8000"
|
|
profiles: ["full"]
|
|
|
|
# Celery worker / beat 暂未启用(P5 的 subprocess 模式已满足脚本执行需求)。
|
|
# 如需后续切换到 Celery 版,取消下面两段注释 + 在 app/tasks/ 下添加 celery_app。
|
|
# worker:
|
|
# build:
|
|
# context: ./backend
|
|
# dockerfile: docker/Dockerfile
|
|
# env_file: .env
|
|
# command: ["celery", "-A", "app.tasks.celery_app", "worker", "--loglevel=info"]
|
|
# depends_on:
|
|
# - backend
|
|
# - redis
|
|
# profiles: ["full"]
|
|
# beat:
|
|
# build:
|
|
# context: ./backend
|
|
# dockerfile: docker/Dockerfile
|
|
# env_file: .env
|
|
# command: ["celery", "-A", "app.tasks.celery_app", "beat", "--loglevel=info"]
|
|
# depends_on:
|
|
# - backend
|
|
# - redis
|
|
# profiles: ["full"]
|
|
|
|
frontend:
|
|
build:
|
|
context: ./frontend
|
|
dockerfile: Dockerfile
|
|
container_name: loom-frontend
|
|
restart: unless-stopped
|
|
volumes:
|
|
- ./docker/nginx.conf:/etc/nginx/conf.d/default.conf:ro
|
|
ports:
|
|
- "80:80"
|
|
depends_on:
|
|
- backend
|
|
profiles: ["full"]
|
|
|
|
volumes:
|
|
postgres_data:
|
|
redis_data:
|