#1: fix webmail healthcheck - Next standalone binds IPv4-only, wget resolved localhost to ::1
Verified live via WSL Docker (docker compose up --wait): every other F0 service came up healthy, but web stayed unhealthy. Root cause was two compounding issues, both invisible to static review: 1. Docker auto-sets HOSTNAME to the container ID; Next's standalone server.js honors that env var and binds only to it instead of all interfaces. Fixed by explicitly setting ENV HOSTNAME=0.0.0.0 in the Dockerfile, after Docker's automatic assignment. 2. Even bound to 0.0.0.0 (IPv4), the healthcheck's `wget http://localhost` resolved localhost to ::1 (IPv6) first inside the container, where nothing was listening. Fixed by pointing the healthcheck at 127.0.0.1 explicitly instead of localhost. Full stack (db, redis, migrate, auth, storage, protocols, web) now reaches healthy end-to-end under docker compose up --wait.
This commit is contained in:
1 parent
096263e0e9
commit
7c91182111
2 files changed
+5
-1
No files matched your search
+1
-1
@@ -118,7 +118,7 @@ services:
|
|||||||
auth: { condition: service_healthy }
|
auth: { condition: service_healthy }
|
||||||
storage: { condition: service_healthy }
|
storage: { condition: service_healthy }
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD-SHELL", "wget -qO- http://localhost:3000/health || exit 1"]
|
test: ["CMD-SHELL", "wget -qO- http://127.0.0.1:3000/health || exit 1"]
|
||||||
interval: 10s
|
interval: 10s
|
||||||
timeout: 5s
|
timeout: 5s
|
||||||
retries: 5
|
retries: 5
|
||||||
|
|||||||
@@ -11,4 +11,8 @@ COPY --from=build /app/.next/standalone ./
|
|||||||
COPY --from=build /app/.next/static ./.next/static
|
COPY --from=build /app/.next/static ./.next/static
|
||||||
COPY --from=build /app/public ./public
|
COPY --from=build /app/public ./public
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
|
# Docker sets HOSTNAME to the container ID by default; Next's standalone
|
||||||
|
# server.js honors that env var and binds only to it, refusing localhost
|
||||||
|
# (and thus the healthcheck). Force it to listen on every interface.
|
||||||
|
ENV HOSTNAME=0.0.0.0
|
||||||
CMD ["node", "server.js"]
|
CMD ["node", "server.js"]
|
||||||
Reference in new issue
Block a user