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
Co-authored-by: Cursor <cursoragent@cursor.com>
79 lines
1.9 KiB
YAML
79 lines
1.9 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"
|
|
volumes:
|
|
- ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
|
|
depends_on:
|
|
- backend
|
|
- admin
|
|
restart: always
|
|
networks:
|
|
- app-network
|
|
|
|
networks:
|
|
app-network:
|
|
driver: bridge
|
|
|
|
volumes:
|
|
db_data:
|