🐛 fix(deploy): 修 unified backend 与 frontend 抢占宿主 10003 冲突

上一版把 frontend 与 backend 都映射 10003:8000,会触发 docker 启动时
"bind: address already in use"。修正:

- docker-compose.yml backend ports 改为 expose: ["8000"]——不映射宿主机,
  仅在 docker 网络 gemold_network 内被 frontend 经 backend:8000 反代访问
- .env.example 删除 BACKEND_PORT 字段(不再需要)
- PORT_CONFIG / DEPLOY_PORT 端口映射表/示例同步:unified backend 不暴露
  宿主机端口,统一经前端 /api 反代

验证:yaml 渲染后无任何 service 对抢宿主端口(unified 仅 frontend 暴露
$FRONTEND_PORT=10003;moldinsight-only 仅 moldinsight 暴露 10003;
inventory-only 仅 inventory 暴露 10004)。

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
2026-09-26 20:56:20 +08:00
parent cf465d28e2
commit b934b737e8
4 changed files with 19 additions and 16 deletions
+4 -3
View File
@@ -76,9 +76,10 @@ services:
image: gemold-backend:latest
container_name: gemold_backend
command: ["python", "-m", "uvicorn", "entrypoints.unified:app", "--host", "0.0.0.0", "--port", "8000"]
ports:
# 不推荐直接访问(应通过 frontend 反代同域访问 /api);保留端口供调试
- "${BACKEND_PORT:-10003}:8000"
# 不映射端口到宿主机:backend 仅供 frontend 反代(docker 网络内 backend:8000 互通),
# 避免与 frontend 抢占宿主 10003。BACKEND_PORT 仍保留以便调试时临时开放。
expose:
- "8000"
environment:
<<: *base_env
ADMIN_USERNAME: ${ADMIN_USERNAME:-admin}