160 行
5.1 KiB
YAML
160 行
5.1 KiB
YAML
name: honghuang
|
||
|
||
# 《洪荒大陆》本地开发环境
|
||
# 一键启动:PostgreSQL 16 + Nakama 3.x + Valkey + Nacos 2.x
|
||
#
|
||
# 前置:
|
||
# cp .env.example .env
|
||
# docker compose up -d
|
||
#
|
||
# 访问:
|
||
# Nakama 端口:7349(gRPC) / 7350(Realtime HTTP) / 7351(Console)
|
||
# PostgreSQL:localhost:5432
|
||
# Valkey: localhost:6379
|
||
# Nacos: http://localhost:8848/nacos (admin/admin)
|
||
|
||
services:
|
||
# -----------------------------------------------------------------------------
|
||
# PostgreSQL 16
|
||
# - 默认创建 nakama 库供 Nakama 自身使用
|
||
# - 通过 docker/postgres/init-honghuang.sh 自动创建 honghuang 库并执行迁移/seed
|
||
# -----------------------------------------------------------------------------
|
||
postgres:
|
||
container_name: honghuang-postgres
|
||
build:
|
||
context: .
|
||
dockerfile: docker/postgres/Dockerfile
|
||
environment:
|
||
POSTGRES_USER: ${POSTGRES_USER:-postgres}
|
||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-postgres}
|
||
POSTGRES_DB: ${POSTGRES_DB:-nakama}
|
||
HONGHUANG_DB: ${HONGHUANG_DB:-honghuang}
|
||
PGDATA: /var/lib/postgresql/data/pgdata
|
||
volumes:
|
||
- postgres_data:/var/lib/postgresql/data
|
||
ports:
|
||
- "5432:5432"
|
||
healthcheck:
|
||
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-postgres} -d ${POSTGRES_DB:-nakama}"]
|
||
interval: 5s
|
||
timeout: 5s
|
||
retries: 10
|
||
networks:
|
||
- honghuang-net
|
||
|
||
# -----------------------------------------------------------------------------
|
||
# Valkey 8(Redis 兼容缓存)
|
||
# -----------------------------------------------------------------------------
|
||
valkey:
|
||
container_name: honghuang-valkey
|
||
image: swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/valkey/valkey:8-alpine
|
||
volumes:
|
||
- valkey_data:/data
|
||
ports:
|
||
- "6379:6379"
|
||
healthcheck:
|
||
test: ["CMD", "valkey-cli", "ping"]
|
||
interval: 5s
|
||
timeout: 3s
|
||
retries: 10
|
||
networks:
|
||
- honghuang-net
|
||
|
||
# -----------------------------------------------------------------------------
|
||
# Nacos 2.x 配置中心(standalone + Derby,仅本地开发)
|
||
# -----------------------------------------------------------------------------
|
||
nacos:
|
||
container_name: honghuang-nacos
|
||
image: swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/nacos/nacos-server:v2.4.3
|
||
environment:
|
||
MODE: standalone
|
||
SPRING_DATASOURCE_PLATFORM: derby
|
||
NACOS_AUTH_ENABLE: "false"
|
||
NACOS_CORE_AUTH_ENABLED: "false"
|
||
volumes:
|
||
- nacos_data:/home/nacos/data
|
||
ports:
|
||
- "8848:8848"
|
||
healthcheck:
|
||
test: ["CMD-SHELL", "curl -fsS http://localhost:8848/nacos/v1/console/health/readiness || exit 1"]
|
||
interval: 5s
|
||
timeout: 5s
|
||
retries: 30
|
||
networks:
|
||
- honghuang-net
|
||
|
||
# -----------------------------------------------------------------------------
|
||
# Nacos 配置导入(一次性初始化容器)
|
||
# - 自动创建 namespace id = honghuang
|
||
# - 将 configs/nacos/*.yaml 导入 Nacos,dataId 为文件名,group = DEFAULT_GROUP
|
||
# -----------------------------------------------------------------------------
|
||
nacos-init:
|
||
container_name: honghuang-nacos-init
|
||
build:
|
||
context: .
|
||
dockerfile: docker/nacos/Dockerfile
|
||
depends_on:
|
||
nacos:
|
||
condition: service_healthy
|
||
environment:
|
||
NACOS_SERVER: honghuang-nacos:8848
|
||
NACOS_NAMESPACE: ${NACOS_NAMESPACE:-honghuang}
|
||
volumes:
|
||
- ./configs/nacos:/configs:ro
|
||
restart: "no"
|
||
networks:
|
||
- honghuang-net
|
||
|
||
# -----------------------------------------------------------------------------
|
||
# Nakama 3.x + 洪荒大陆 Go 插件
|
||
# - 先执行 Nakama 自身 migrate up(使用 nakama 库)
|
||
# - 加载 docker/nakama/config.yml 与编译好的 honghuang-server.so
|
||
# -----------------------------------------------------------------------------
|
||
nakama:
|
||
container_name: honghuang-nakama
|
||
build:
|
||
context: .
|
||
dockerfile: docker/nakama/Dockerfile
|
||
depends_on:
|
||
postgres:
|
||
condition: service_healthy
|
||
nacos:
|
||
condition: service_healthy
|
||
valkey:
|
||
condition: service_healthy
|
||
nacos-init:
|
||
condition: service_completed_successfully
|
||
environment:
|
||
DATABASE_URL: postgres://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@postgres:5432/${HONGHUANG_DB:-honghuang}?sslmode=disable
|
||
NACOS_SERVER: honghuang-nacos
|
||
NACOS_NAMESPACE: ${NACOS_NAMESPACE:-honghuang}
|
||
entrypoint:
|
||
- "/bin/sh"
|
||
- "-ecx"
|
||
- >
|
||
/nakama/nakama migrate up --database.address ${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@postgres:5432/${POSTGRES_DB:-nakama} &&
|
||
exec /nakama/nakama --config /nakama/data/config.yml --database.address ${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@postgres:5432/${POSTGRES_DB:-nakama}
|
||
ports:
|
||
- "7349:7349"
|
||
- "7350:7350"
|
||
- "7351:7351"
|
||
volumes:
|
||
- nakama_data:/nakama/data
|
||
networks:
|
||
- honghuang-net
|
||
healthcheck:
|
||
test: ["CMD", "/nakama/nakama", "healthcheck"]
|
||
interval: 10s
|
||
timeout: 5s
|
||
retries: 10
|
||
|
||
volumes:
|
||
postgres_data:
|
||
valkey_data:
|
||
nacos_data:
|
||
nakama_data:
|
||
|
||
networks:
|
||
honghuang-net:
|
||
driver: bridge
|