Ver código fonte

fix(deploy): 固定容器内 PORT=3000,避免 .env 主机端口泄漏致健康检查失败

.env 里的 PORT 是宿主机映射端口("${PORT:-13000}:3000"),不该透传进容器。
但 env_file 会把整份 .env 灌入容器,导致 next start 读到 PORT=13000 监听错端口,
上方 13000->3000 映射与 HEALTHCHECK(探 :3000)双双落空,容器变 unhealthy、WebUI 不可达。
environment 优先级高于 env_file,在此显式钉死 PORT=3000 中和该泄漏。

Co-Authored-By: Claude <noreply@anthropic.com>
lkatzey 3 dias atrás
pai
commit
10d856e462
1 arquivos alterados com 8 adições e 0 exclusões
  1. 8 0
      docker-compose.yml

+ 8 - 0
docker-compose.yml

@@ -20,6 +20,14 @@ services:
     env_file:
       - .env
     environment:
+      # PIN container's listening port to 3000. `PORT` in .env is the HOST
+      # port for the mapping above ("${PORT:-13000}:3000") — it must NOT reach
+      # Next.js inside the container, or `next start` reads PORT=13000 and
+      # listens on the wrong port, so both the 13000->3000 mapping and the
+      # HEALTHCHECK (which probes :3000) miss it → container goes unhealthy
+      # and the WebUI is unreachable. `environment` overrides `env_file`, so
+      # this neutralizes the PORT leaked by env_file below.
+      - PORT=3000
       - OUTPUT_DIR=${OUTPUT_DIR:-/app/output}
       - OUTPUT_RETENTION_DAYS=${OUTPUT_RETENTION_DAYS:-30}
       - TZ=${TZ:-Asia/Shanghai}