63 lines
1.8 KiB
YAML
63 lines
1.8 KiB
YAML
|
|
# soul-api 蓝绿部署 - 支持无缝切换
|
|||
|
|
# blue=9001, green=9002,部署时先启新实例,健康检查通过后切换 Nginx,再停旧实例
|
|||
|
|
# 用法:见 deploy.py --mode docker
|
|||
|
|
|
|||
|
|
services:
|
|||
|
|
soul-api-blue:
|
|||
|
|
image: soul-api:latest
|
|||
|
|
container_name: soul-api-blue
|
|||
|
|
restart: "no"
|
|||
|
|
environment:
|
|||
|
|
- REDIS_URL=redis://:soul-docker-redis@redis:6379/0
|
|||
|
|
- GIN_MODE=release
|
|||
|
|
- APP_ENV=production
|
|||
|
|
# 测试/预发布环境可设 SKIP_PROD_SECRET_CHECK=staging,正式生产请使用真实密钥并移除此项
|
|||
|
|
- SKIP_PROD_SECRET_CHECK=staging
|
|||
|
|
ports:
|
|||
|
|
- "9001:8080"
|
|||
|
|
volumes:
|
|||
|
|
- soul_uploads:/app/uploads
|
|||
|
|
depends_on:
|
|||
|
|
- redis
|
|||
|
|
healthcheck:
|
|||
|
|
test: ["CMD", "wget", "-q", "-O", "-", "http://localhost:8080/health"]
|
|||
|
|
interval: 5s
|
|||
|
|
timeout: 5s
|
|||
|
|
retries: 10
|
|||
|
|
start_period: 15s
|
|||
|
|
|
|||
|
|
soul-api-green:
|
|||
|
|
image: soul-api:latest
|
|||
|
|
container_name: soul-api-green
|
|||
|
|
restart: "no"
|
|||
|
|
environment:
|
|||
|
|
- REDIS_URL=redis://:soul-docker-redis@redis:6379/0
|
|||
|
|
- GIN_MODE=release
|
|||
|
|
- APP_ENV=production
|
|||
|
|
- SKIP_PROD_SECRET_CHECK=staging
|
|||
|
|
ports:
|
|||
|
|
- "9002:8080"
|
|||
|
|
volumes:
|
|||
|
|
- soul_uploads:/app/uploads
|
|||
|
|
depends_on:
|
|||
|
|
- redis
|
|||
|
|
healthcheck:
|
|||
|
|
test: ["CMD", "wget", "-q", "-O", "-", "http://localhost:8080/health"]
|
|||
|
|
interval: 5s
|
|||
|
|
timeout: 5s
|
|||
|
|
retries: 10
|
|||
|
|
start_period: 15s
|
|||
|
|
|
|||
|
|
redis:
|
|||
|
|
# 与 soul-api 一并打包上传,使用本地 DaoCloud 镜像名(与 pack 中 docker save 一致)
|
|||
|
|
image: docker.m.daocloud.io/library/redis:7-alpine
|
|||
|
|
container_name: soul-redis
|
|||
|
|
command: redis-server --appendonly yes --requirepass "soul-docker-redis"
|
|||
|
|
volumes:
|
|||
|
|
- redis_data:/data
|
|||
|
|
restart: unless-stopped
|
|||
|
|
|
|||
|
|
volumes:
|
|||
|
|
redis_data:
|
|||
|
|
soul_uploads:
|