cangku/deploy/production/docker-compose.yml

117 lines
3.3 KiB
YAML

name: cangku
services:
mysql:
image: mysql:8.0.39
container_name: cangku-mysql
restart: unless-stopped
env_file:
- /opt/cangku/shared/mysql.env
command:
- --character-set-server=utf8mb4
- --collation-server=utf8mb4_unicode_ci
ports:
- 127.0.0.1:3307:3306
volumes:
- /opt/cangku/data/mysql:/var/lib/mysql
- ../../backend/database/init.sql:/docker-entrypoint-initdb.d/001-init.sql:ro
- ../../backend/database/summary_tables.sql:/docker-entrypoint-initdb.d/002-summary-tables.sql:ro
healthcheck:
test: ["CMD-SHELL", "mysqladmin ping -h 127.0.0.1 -uroot -p$$MYSQL_ROOT_PASSWORD --silent"]
interval: 5s
timeout: 5s
retries: 30
start_period: 30s
networks:
- cangku-internal
redis:
image: redis:7.4-alpine
container_name: cangku-redis
restart: unless-stopped
env_file:
- /opt/cangku/shared/redis.env
command: ["sh", "-c", "exec redis-server --appendonly yes --save 60 1000 --requirepass \"$$REDIS_PASSWORD\""]
volumes:
- /opt/cangku/data/redis:/data
healthcheck:
test: ["CMD-SHELL", "REDISCLI_AUTH=$$REDIS_PASSWORD redis-cli ping | grep -q PONG"]
interval: 5s
timeout: 5s
retries: 20
start_period: 10s
networks:
- cangku-internal
redis-gateway:
image: haproxy:3.0-alpine
container_name: cangku-redis-gateway
restart: unless-stopped
ports:
- 6380:6380
volumes:
- ./haproxy-redis.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
- /opt/cangku/shared/redis-tls.pem:/usr/local/etc/haproxy/certs/redis.pem:ro
depends_on:
redis:
condition: service_healthy
networks:
- cangku-internal
backend:
build:
context: ../../backend
dockerfile: Dockerfile.production
container_name: cangku-backend
restart: unless-stopped
env_file:
- /opt/cangku/shared/backend.env
ports:
- 127.0.0.1:4090:4090
volumes:
- /opt/cangku/data/backend:/app/runtime
depends_on:
mysql:
condition: service_healthy
redis:
condition: service_healthy
healthcheck:
test: ["CMD", "node", "-e", "const s=require('node:net').connect(4090,'127.0.0.1',()=>{s.end();process.exit(0)});s.setTimeout(3000,()=>process.exit(1));s.on('error',()=>process.exit(1))"]
interval: 10s
timeout: 5s
retries: 18
start_period: 30s
networks:
- cangku-internal
bootstrap:
build:
context: ../../remote-access/server
dockerfile: Dockerfile.production
container_name: cangku-bootstrap
restart: unless-stopped
env_file:
- /opt/cangku/shared/bootstrap.env
ports:
- 127.0.0.1:4092:4092
volumes:
- /opt/cangku/data/bootstrap:/var/lib/cangku-bootstrap
- /etc/ssh/ssh_host_ed25519_key.pub:/etc/ssh/ssh_host_ed25519_key.pub:ro
depends_on:
mysql:
condition: service_healthy
redis:
condition: service_healthy
healthcheck:
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://127.0.0.1:4092/health', timeout=3)"]
interval: 10s
timeout: 5s
retries: 12
start_period: 10s
networks:
- cangku-internal
networks:
cangku-internal:
name: cangku-internal