104 lines
2.7 KiB
YAML
104 lines
2.7 KiB
YAML
version: '3.8'
|
|
|
|
services:
|
|
# ========== Gitea Git 服务器 ==========
|
|
gitea:
|
|
image: gitea/gitea:latest
|
|
container_name: gitea
|
|
restart: always
|
|
environment:
|
|
- USER_UID=1000
|
|
- USER_GID=1000
|
|
- GITEA__database__DB_TYPE=sqlite3
|
|
- GITEA__server__DOMAIN=git.gch3n.online
|
|
- GITEA__server__ROOT_URL=https://git.gch3n.online/
|
|
- GITEA__server__SSH_DOMAIN=git.gch3n.online
|
|
- GITEA__server__SSH_PORT=2222
|
|
- GITEA__server__SSH_LISTEN_PORT=2222
|
|
- GITEA__service__DISABLE_REGISTRATION=false
|
|
- GITEA__service__REQUIRE_SIGNIN_VIEW=false
|
|
- GITEA__webhook__ALLOWED_HOST_LIST=external,loopback
|
|
ports:
|
|
- "127.0.0.1:3000:3000"
|
|
- "2222:2222"
|
|
volumes:
|
|
- ./data/gitea:/data
|
|
- /etc/timezone:/etc/timezone:ro
|
|
- /etc/localtime:/etc/localtime:ro
|
|
networks:
|
|
- gch3n-network
|
|
|
|
# ========== Nginx 反向代理 ==========
|
|
nginx:
|
|
image: nginx:alpine
|
|
container_name: nginx
|
|
restart: always
|
|
ports:
|
|
- "80:80"
|
|
- "443:443"
|
|
volumes:
|
|
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
|
|
- ./nginx/conf.d:/etc/nginx/conf.d:ro
|
|
- ./data/certbot/conf:/etc/letsencrypt:ro
|
|
- ./data/certbot/www:/var/www/certbot:ro
|
|
depends_on:
|
|
- gitea
|
|
networks:
|
|
- gch3n-network
|
|
|
|
# ========== Certbot SSL 证书 ==========
|
|
certbot:
|
|
image: certbot/certbot
|
|
container_name: certbot
|
|
volumes:
|
|
- ./data/certbot/conf:/etc/letsencrypt
|
|
- ./data/certbot/www:/var/www/certbot
|
|
entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12h & wait $${!}; done;'"
|
|
networks:
|
|
- gch3n-network
|
|
|
|
# ========== 应用蓝绿部署 ==========
|
|
app-blue:
|
|
image: gch3n/app:latest
|
|
container_name: app-blue
|
|
restart: always
|
|
expose:
|
|
- "3001"
|
|
environment:
|
|
- PORT=3001
|
|
- DEPLOY_COLOR=blue
|
|
healthcheck:
|
|
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:3001/health"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 3
|
|
start_period: 10s
|
|
networks:
|
|
- gch3n-network
|
|
deploy:
|
|
replicas: 0 # 初始状态,由部署脚本控制
|
|
|
|
app-green:
|
|
image: gch3n/app:latest
|
|
container_name: app-green
|
|
restart: always
|
|
expose:
|
|
- "3002"
|
|
environment:
|
|
- PORT=3002
|
|
- DEPLOY_COLOR=green
|
|
healthcheck:
|
|
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:3002/health"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 3
|
|
start_period: 10s
|
|
networks:
|
|
- gch3n-network
|
|
deploy:
|
|
replicas: 0 # 初始状态,由部署脚本控制
|
|
|
|
networks:
|
|
gch3n-network:
|
|
driver: bridge
|