250 lines
6.6 KiB
YAML
250 lines
6.6 KiB
YAML
# 全量服务部署 (前端 + 后端 + 游戏服 + 数据库 + 中间件 + Nginx)
|
|
# 使用方法: docker-compose -f docker-compose.all.yml up -d --build
|
|
services:
|
|
# ----------------------------------------------------
|
|
# 1. 业务后端 (Bindbox Game Backend)
|
|
# ----------------------------------------------------
|
|
bindbox-game:
|
|
image: zfc931912343/bindbox-game:v1.15
|
|
container_name: bindbox-game
|
|
restart: always
|
|
# ports:
|
|
# - "9991:9991" (Internal only)
|
|
volumes:
|
|
- ../bindbox_game/logs:/app/logs
|
|
- ../bindbox_game/configs:/app/configs
|
|
environment:
|
|
- ACTIVE_ENV=pro
|
|
- TZ=Asia/Shanghai
|
|
networks:
|
|
- bindbox_net
|
|
logging:
|
|
driver: "json-file"
|
|
options:
|
|
max-size: "10m"
|
|
max-file: "3"
|
|
depends_on:
|
|
- mysql
|
|
- redis
|
|
|
|
# ----------------------------------------------------
|
|
# 2. 管理后台 (Admin Web)
|
|
# ----------------------------------------------------
|
|
admin-web:
|
|
build: ../bindbox_game/web/admin
|
|
container_name: bindbox-admin-web
|
|
restart: always
|
|
networks:
|
|
- bindbox_net
|
|
logging:
|
|
driver: "json-file"
|
|
options:
|
|
max-size: "10m"
|
|
max-file: "3"
|
|
|
|
# ----------------------------------------------------
|
|
# 3. 游戏数据库 (CockroachDB for Nakama)
|
|
# ----------------------------------------------------
|
|
nakama-db:
|
|
image: cockroachdb/cockroach:latest-v23.1
|
|
container_name: nakama-db
|
|
command: start-single-node --insecure --store=attrs=ssd,path=/var/lib/cockroach/ --cache=.25 --max-sql-memory=.25
|
|
restart: always
|
|
volumes:
|
|
- nakama-db-data:/var/lib/cockroach
|
|
|
|
healthcheck:
|
|
test: [ "CMD", "curl", "-f", "http://localhost:8080/health?ready=1" ]
|
|
interval: 3s
|
|
timeout: 3s
|
|
retries: 5
|
|
environment:
|
|
- TZ=Asia/Shanghai
|
|
networks:
|
|
- bindbox_net
|
|
logging:
|
|
driver: "json-file"
|
|
options:
|
|
max-size: "10m"
|
|
max-file: "3"
|
|
|
|
# ----------------------------------------------------
|
|
# 4. 游戏服务器 (Nakama)
|
|
# ----------------------------------------------------
|
|
nakama:
|
|
image: zfc931912343/bindbox-saolei:v1.6
|
|
container_name: nakama-server
|
|
environment:
|
|
- MINESWEEPER_BACKEND_URL=http://bindbox-game:9991/api/internal
|
|
- TZ=Asia/Shanghai
|
|
entrypoint:
|
|
- "/bin/sh"
|
|
- "-ecx"
|
|
- "/nakama/nakama migrate up --database.address root@nakama-db:26257 && exec /nakama/nakama --name nakama1 --database.address root@nakama-db:26257 --logger.level DEBUG --session.token_expiry_sec 7200 --metrics.prometheus_port 9100 --runtime.path /nakama/modules --matchmaker.interval_sec 1 --matchmaker.max_intervals 5"
|
|
restart: always
|
|
depends_on:
|
|
nakama-db:
|
|
condition: service_healthy
|
|
bindbox-game:
|
|
condition: service_started
|
|
volumes:
|
|
- nakama-data:/nakama/data
|
|
|
|
healthcheck:
|
|
test: [ "CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://bindbox-game:9991/" ]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
networks:
|
|
- bindbox_net
|
|
logging:
|
|
driver: "json-file"
|
|
options:
|
|
max-size: "10m"
|
|
max-file: "3"
|
|
|
|
# ----------------------------------------------------
|
|
# 5. MySQL Database (For Bindbox Backend)
|
|
# ----------------------------------------------------
|
|
mysql:
|
|
image: mysql:8.0
|
|
container_name: bindbox-mysql
|
|
restart: always
|
|
environment:
|
|
MYSQL_ROOT_PASSWORD: "123456"
|
|
MYSQL_DATABASE: "bindbox_game"
|
|
TZ: Asia/Shanghai
|
|
command: --default-authentication-plugin=mysql_native_password
|
|
volumes:
|
|
- mysql_data:/var/lib/mysql
|
|
networks:
|
|
- bindbox_net
|
|
logging:
|
|
driver: "json-file"
|
|
options:
|
|
max-size: "10m"
|
|
max-file: "3"
|
|
|
|
# ----------------------------------------------------
|
|
# 6. Redis (For Bindbox Backend)
|
|
# ----------------------------------------------------
|
|
redis:
|
|
image: redis:7.0
|
|
container_name: bindbox-redis
|
|
restart: always
|
|
volumes:
|
|
- redis_data:/data
|
|
networks:
|
|
- bindbox_net
|
|
logging:
|
|
driver: "json-file"
|
|
options:
|
|
max-size: "10m"
|
|
max-file: "3"
|
|
|
|
# ----------------------------------------------------
|
|
# 7. Nginx Gateway
|
|
# ----------------------------------------------------
|
|
nginx:
|
|
image: nginx:latest
|
|
container_name: bindbox-nginx
|
|
restart: always
|
|
ports:
|
|
- "80:80"
|
|
- "443:443"
|
|
volumes:
|
|
- ./nginx/conf.d:/etc/nginx/conf.d
|
|
- ./nginx/ssl:/etc/nginx/ssl
|
|
depends_on:
|
|
- bindbox-game
|
|
- admin-web
|
|
- nakama
|
|
networks:
|
|
- bindbox_net
|
|
logging:
|
|
driver: "json-file"
|
|
options:
|
|
max-size: "10m"
|
|
|
|
# ----------------------------------------------------
|
|
# 8. Loki (Log Storage)
|
|
# ----------------------------------------------------
|
|
loki:
|
|
image: grafana/loki:3.0.0
|
|
container_name: bindbox-loki
|
|
restart: always
|
|
# ports:
|
|
# - "3100:3100"
|
|
volumes:
|
|
- ./loki/loki-config.yaml:/etc/loki/local-config.yaml
|
|
- loki_data:/loki
|
|
command: -config.file=/etc/loki/local-config.yaml
|
|
networks:
|
|
- bindbox_net
|
|
logging:
|
|
driver: "json-file"
|
|
options:
|
|
max-size: "10m"
|
|
max-file: "3"
|
|
|
|
# ----------------------------------------------------
|
|
# 9. Promtail (Log Collector)
|
|
# ----------------------------------------------------
|
|
promtail:
|
|
image: grafana/promtail:3.0.0
|
|
container_name: bindbox-promtail
|
|
restart: always
|
|
volumes:
|
|
- ./loki/promtail-config.yaml:/etc/promtail/config.yaml
|
|
- /var/lib/docker/containers:/var/lib/docker/containers:ro
|
|
- /var/run/docker.sock:/var/run/docker.sock
|
|
- ../bindbox_game/logs:/var/log/bindbox-game:ro
|
|
command: -config.file=/etc/promtail/config.yaml
|
|
networks:
|
|
- bindbox_net
|
|
depends_on:
|
|
- loki
|
|
logging:
|
|
driver: "json-file"
|
|
options:
|
|
max-size: "10m"
|
|
max-file: "3"
|
|
|
|
# ----------------------------------------------------
|
|
# 10. Grafana (Visualization)
|
|
# ----------------------------------------------------
|
|
grafana:
|
|
image: grafana/grafana:latest
|
|
container_name: bindbox-grafana
|
|
restart: always
|
|
ports:
|
|
- "3000:3000"
|
|
environment:
|
|
- GF_SECURITY_ADMIN_PASSWORD=admin
|
|
- GF_USERS_ALLOW_SIGN_UP=false
|
|
volumes:
|
|
- grafana_data:/var/lib/grafana
|
|
networks:
|
|
- bindbox_net
|
|
depends_on:
|
|
- loki
|
|
logging:
|
|
driver: "json-file"
|
|
options:
|
|
max-size: "10m"
|
|
max-file: "3"
|
|
|
|
volumes:
|
|
nakama-db-data:
|
|
nakama-data:
|
|
mysql_data:
|
|
redis_data:
|
|
loki_data:
|
|
grafana_data:
|
|
|
|
|
|
networks:
|
|
bindbox_net:
|
|
name: bindbox_net
|
|
driver: bridge
|