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>
18 lines
656 B
Docker
18 lines
656 B
Docker
FROM node:20-alpine AS deps
|
|
WORKDIR /app
|
|
COPY package.json ./
|
|
RUN npm install --omit=dev --no-audit --no-fund && npm install --no-save tsx@4.19.2 typescript@5.7.2
|
|
|
|
FROM node:20-alpine AS runtime
|
|
WORKDIR /app
|
|
ENV NODE_ENV=production
|
|
COPY --from=deps /app/node_modules ./node_modules
|
|
COPY package.json tsconfig.json ./
|
|
COPY src ./src
|
|
EXPOSE 3000
|
|
# 127.0.0.1, not localhost: busybox wget resolves localhost to ::1 first and
|
|
# the server binds IPv4 only, so a localhost check would wrongly fail.
|
|
HEALTHCHECK --interval=15s --timeout=3s --start-period=10s --retries=3 \
|
|
CMD wget -qO- http://127.0.0.1:3000/health || exit 1
|
|
CMD ["npx", "tsx", "src/server.ts"]
|