fix(docker): healthcheck must hit 127.0.0.1, not localhost
The servers bind IPv4 (0.0.0.0) only. busybox wget resolves `localhost` to ::1 first and does not fall back to IPv4, so the healthcheck failed with "connection refused" and the container showed as unhealthy while serving fine. Verified on the production api container. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -28,6 +28,8 @@ ENV NODE_ENV=production
|
||||
COPY . .
|
||||
WORKDIR /app/apps/api
|
||||
EXPOSE 4000
|
||||
# Use 127.0.0.1, not localhost: the server binds IPv4 only, and busybox wget
|
||||
# resolves localhost to ::1 first — which would refuse and fail the check.
|
||||
HEALTHCHECK --interval=20s --timeout=4s --start-period=20s --retries=3 \
|
||||
CMD wget -qO- http://localhost:4000/health || exit 1
|
||||
CMD wget -qO- http://127.0.0.1:4000/health || exit 1
|
||||
CMD ["pnpm", "start"]
|
||||
|
||||
Reference in New Issue
Block a user