Files
wecom-ai-assistant/deploy/docker-compose.prod.yml
bujie9527 b715755b76
Some checks failed
Build and Deploy / test-backend (push) Has been cancelled
Build and Deploy / build-backend (push) Has been cancelled
Build and Deploy / build-admin (push) Has been cancelled
Deploy to Production / build-backend (push) Has been cancelled
Deploy to Production / deploy (push) Has been cancelled
feat: backend env config upgrade - multi-env (dev/prod), DB_* support, Docker compatible
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-06 12:07:02 +08:00

84 lines
2.1 KiB
YAML

# 生产环境部署配置
# 用途:云端生产环境一键部署
# 使用: docker compose -f docker-compose.prod.yml --env-file .env.prod up -d
version: '3.8'
services:
db:
image: postgres:16-alpine
environment:
POSTGRES_USER: ${POSTGRES_USER:-postgres}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB:-wecom_ai}
volumes:
- db_data:/var/lib/postgresql/data
restart: always
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-postgres} -d ${POSTGRES_DB:-wecom_ai}"]
interval: 10s
timeout: 5s
retries: 5
networks:
- app-network
backend:
image: registry.667788.cool/wecom-backend:${TAG:-latest}
env_file:
- .env.prod
environment:
DATABASE_URL: ${DATABASE_URL}
DATABASE_URL_SYNC: ${DATABASE_URL_SYNC}
depends_on:
db:
condition: service_healthy
restart: always
healthcheck:
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8000/api/health')"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
networks:
- app-network
admin:
image: registry.667788.cool/wecom-admin:${TAG:-latest}
env_file:
- .env.prod
restart: always
healthcheck:
test: ["CMD", "node", "-e", "require('http').get('http://localhost:3000', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
networks:
- app-network
nginx:
image: registry.667788.cool/wecom-nginx:${TAG:-latest}
ports:
- "80:80"
- "443:443"
# 注意:镜像构建时已经包含了配置,无需挂载
# 如果需要覆盖配置,取消下面的注释并确保 nginx.conf 路径正确
# volumes:
# - ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
environment:
- NGINX_HOST=_
- NGINX_PORT=80
depends_on:
- backend
- admin
restart: always
networks:
- app-network
networks:
app-network:
driver: bridge
volumes:
db_data: