-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
50 lines (43 loc) · 1.7 KB
/
Copy pathDockerfile
File metadata and controls
50 lines (43 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
FROM node:25-alpine AS deps
WORKDIR /app
RUN npm install -g pnpm@11.15.1
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
RUN pnpm install --frozen-lockfile
FROM node:25-alpine AS dev
WORKDIR /app
RUN npm install -g pnpm@11.15.1
COPY --from=deps /app/node_modules ./node_modules
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
EXPOSE 3000
CMD ["npm", "run", "dev"]
FROM node:25-alpine AS builder
WORKDIR /app
RUN npm install -g pnpm@11.15.1
COPY --from=deps /app/node_modules ./node_modules
COPY . .
ENV NEXT_TELEMETRY_DISABLED=1
# Backend API URL (can be overridden at build time or runtime)
ARG BACKEND_URL=http://127.0.0.1:8000
ENV BACKEND_URL=${BACKEND_URL}
RUN pnpm run build
FROM node:25-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
# Bind to all interfaces (IPv4 + IPv6) so the container port is reachable from the host
ENV HOSTNAME="::"
# Runtime API base URL (override at container start)
ENV BACKEND_URL=http://127.0.0.1:8000
# Standalone output includes only the traced files the app needs —
# no full node_modules install required in the production image.
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
COPY --from=builder /app/public ./public
COPY --from=builder /app/scripts ./scripts
EXPOSE 3000
# Health check — polls the app's /health endpoint every 30 s.
# start-period gives Next.js time to fully initialise before checks begin.
# Container is marked unhealthy after 3 consecutive failures (90 s total).
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD wget -qO- http://localhost:3000/health || exit 1
CMD ["sh", "-c", "node scripts/write-runtime-config.mjs && node server.js"]