Files
deploy.stack/newapi/stack.host.yml
T
cnphpbb f0475ecf36 build(newapi): 切换 host 部署到 prod-dbs 网络并重构变量
- 复用 prod-postgres 与 Dev-Redis,移除宿主机直连
- 变量全部提供默认值,只需 env.cfg 填密码
- 容器名与网络引用同步调整
2026-09-02 19:14:53 +08:00

52 lines
2.7 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# path:: mkdir -pv /data/volumes/newapi/{data,logs}
# pull:: docker compose -p newapi-host --env-file ./newapi/env.cfg -f ./newapi/stack.host.yml pull
# run:: docker compose -p newapi-host --env-file ./newapi/env.cfg -f ./newapi/stack.host.yml up -d
# disc:: 单容器部署:复用 prod-dbs 项目里的 prod-postgresjoin 同一 docker 网络解析)
# disc:: Redis 复用 dbSer/redis 的 Dev-Redis172.22.10.205,固定 IP
# disc:: 项目名 newapi-host,与 stack.yml 全栈部署互不冲突
# disc:: 启动顺序:先 up prod-dbs(确保 prod-dbs_default 网络存在),再 up newapi-host
# disc:: 所有连接变量已内置默认值,复用 env.cfg 只需填密码即可
# disc:: 第一个注册的账号自动成为管理员;生产务必修改 env.cfg 中的全部密码
services:
newapi:
image: ${IMAGE_TAG}
container_name: newapi_host_app
restart: always
command: --log-dir /app/logs
ports:
- "${PORT:-3000}:3000"
networks:
- prod-dbs_default # 加入 prod-dbs 默认网络,用 service 名 postgres 解析 prod-postgres
volumes:
- ${Volumes_Path:-/data/volumes/newapi}/data:/data
- ${Volumes_Path:-/data/volumes/newapi}/logs:/app/logs
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
environment:
# 默认值:DB_HOST=postgres 指向 prod-dbs 项目的 postgres service
# 本机 PG 无 TLS 时显式关闭 SSL(取消下行注释并注释上行):
# - SQL_DSN=postgresql://${DB_USER:-newapi}:${DB_PASSWORD}@${DB_HOST:-postgres}:${DB_PORT:-5432}/${DB_NAME:-new_api}?sslmode=disable
- SQL_DSN=postgresql://${DB_USER:-newapi}:${DB_PASSWORD}@${DB_HOST:-postgres}:${DB_PORT:-5432}/${DB_NAME:-new_api}
# 默认值:REDIS_HOST=172.22.10.205 指向 Dev-RedisdbSer/redis.yml部署,DevNet 网段固定 IP
- REDIS_CONN_STRING=redis://:${REDIS_PASSWORD}@${REDIS_HOST:-172.22.10.205}:${REDIS_PORT:-6379}
- TZ=Asia/Shanghai
- BATCH_UPDATE_ENABLED=true
- ERROR_LOG_ENABLED=true
- NODE_NAME=${NODE_NAME:-newapi-node-1}
- SESSION_SECRET=${SESSION_SECRET:-}
# 可选:独立日志库(PG 或 ClickHouse),不设则日志与业务同库
# - LOG_SQL_DSN=postgresql://${DB_USER}:${DB_PASSWORD}@${DB_HOST:-postgres}:${DB_PORT:-5432}/${DB_NAME:-new_api}_log
# 流式无响应超时(秒),默认 120,出现空补全时调大:
# - STREAMING_TIMEOUT=300
healthcheck:
test: ["CMD-SHELL", "wget -q -O - http://127.0.0.1:3000/api/status >/dev/null || exit 1"]
interval: 30s
timeout: 10s
retries: 3
networks:
prod-dbs_default:
# 引用 prod-dbs 项目自动创建的默认网络,不归本 compose 管
external: true
name: prod-dbs_default