All checks were successful
CI / changes (push) Successful in 7s
CI / changes (pull_request) Successful in 6s
CI / backend-tests (push) Has been skipped
CI / backend-tests (pull_request) Has been skipped
Deploy / changes (push) Successful in 5s
Deploy / build-backend (push) Has been skipped
Deploy / build-worker (push) Has been skipped
Deploy / build-frontend (push) Successful in 2m46s
Deploy / deploy (push) Successful in 50s
Docker auto-sets HOSTNAME to the container id; Next standalone's server.js binds process.env.HOSTNAME, so it listened on the container hostname and the compose healthcheck (TCP 127.0.0.1:3000) was refused → frontend container chronically "(unhealthy)" (cosmetic: Caddy reaches it by service name and the site serves 200). Pin HOSTNAME=0.0.0.0 — the canonical Next.js Docker fix. Diagnosed on prod 2026-06-05.
48 lines
1.6 KiB
Docker
48 lines
1.6 KiB
Docker
# syntax=docker/dockerfile:1.7
|
|
|
|
# ---- deps ----
|
|
FROM node:20-alpine AS deps
|
|
WORKDIR /app
|
|
COPY package.json package-lock.json ./
|
|
# --legacy-peer-deps: Tailwind 4 alpha + React 19 peer-dep mismatches.
|
|
RUN --mount=type=cache,target=/root/.npm \
|
|
npm ci --legacy-peer-deps --no-audit --no-fund
|
|
|
|
|
|
# ---- builder ----
|
|
FROM node:20-alpine AS builder
|
|
WORKDIR /app
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
# NEXT_PUBLIC_* must be present at `npm run build` — Next.js inlines them into
|
|
# the client bundle. Defaults to empty so local `docker build` без build-args не ломается.
|
|
ARG NEXT_PUBLIC_GLITCHTIP_DSN=
|
|
ARG NEXT_PUBLIC_ENVIRONMENT=production
|
|
ENV NEXT_PUBLIC_GLITCHTIP_DSN=$NEXT_PUBLIC_GLITCHTIP_DSN
|
|
ENV NEXT_PUBLIC_ENVIRONMENT=$NEXT_PUBLIC_ENVIRONMENT
|
|
COPY --from=deps /app/node_modules ./node_modules
|
|
COPY . .
|
|
RUN npm run build
|
|
|
|
|
|
# ---- runner ----
|
|
FROM node:20-alpine AS runner
|
|
WORKDIR /app
|
|
# Next.js standalone server.js binds to `process.env.HOSTNAME || '0.0.0.0'`.
|
|
# Docker auto-sets HOSTNAME to the container id, so without this the server binds
|
|
# that hostname and the compose healthcheck (TCP 127.0.0.1:3000) is refused →
|
|
# container shows "(unhealthy)" although it serves fine via Caddy (service name).
|
|
# Pin 0.0.0.0 so it listens on all interfaces and the healthcheck connects.
|
|
ENV NODE_ENV=production \
|
|
NEXT_TELEMETRY_DISABLED=1 \
|
|
PORT=3000 \
|
|
HOSTNAME=0.0.0.0
|
|
|
|
# `node` user (uid 1000) ships with the alpine image.
|
|
COPY --from=builder --chown=node:node /app/public ./public
|
|
COPY --from=builder --chown=node:node /app/.next/standalone ./
|
|
COPY --from=builder --chown=node:node /app/.next/static ./.next/static
|
|
|
|
USER node
|
|
|
|
EXPOSE 3000
|
|
CMD ["node", "server.js"]
|