fix(docker): nginx fails to start on hosts without IPv6 (#2027)

* fix(docker): nginx fails to start on hosts without IPv6

- Detect IPv6 support at runtime and remove `listen [::]` directive
  when unavailable, preventing nginx startup failure on non-IPv6 hosts
- Use `exec` to replace shell with nginx as PID 1 for proper signal
  handling (graceful shutdown on SIGTERM)
- Reformat command from YAML folded scalar to block scalar (no
  functional change)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(docker): harden nginx startup script (Copilot review feedback)

Add `set -e` so envsubst failures exit immediately instead of starting
nginx with an incomplete config. Narrow the sed pattern to match only
the `listen [::]:2026;` directive to avoid accidentally removing future
lines containing [::].

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Gao Mingfei 2026-04-09 15:58:30 +08:00 committed by GitHub
parent 60e0abfdb8
commit 13664e99e7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -69,10 +69,15 @@ services:
environment: environment:
- LANGGRAPH_UPSTREAM=${LANGGRAPH_UPSTREAM:-langgraph:2024} - LANGGRAPH_UPSTREAM=${LANGGRAPH_UPSTREAM:-langgraph:2024}
- LANGGRAPH_REWRITE=${LANGGRAPH_REWRITE:-/} - LANGGRAPH_REWRITE=${LANGGRAPH_REWRITE:-/}
command: > command:
sh -c "envsubst '$$LANGGRAPH_UPSTREAM $$LANGGRAPH_REWRITE' - sh
< /etc/nginx/nginx.conf.template > /etc/nginx/nginx.conf - -c
&& nginx -g 'daemon off;'" - |
set -e
envsubst '$$LANGGRAPH_UPSTREAM $$LANGGRAPH_REWRITE' \
< /etc/nginx/nginx.conf.template > /etc/nginx/nginx.conf
test -e /proc/net/if_inet6 || sed -i '/^[[:space:]]*listen[[:space:]]\+\[::\]:2026;/d' /etc/nginx/nginx.conf
exec nginx -g 'daemon off;'
depends_on: depends_on:
- frontend - frontend
- gateway - gateway