-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
55 lines (44 loc) · 1.93 KB
/
Copy pathDockerfile
File metadata and controls
55 lines (44 loc) · 1.93 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
51
52
53
54
55
# syntax=docker/dockerfile:1
# Lumina LMS — production image.
# Multi-stage build producing a small, non-root runtime from Next.js standalone
# output. Debian slim (glibc) is used so better-sqlite3's prebuilt binary loads
# without compiling; the deps stage still carries a toolchain in case a prebuild
# isn't available for the target platform.
ARG NODE_VERSION=20-bookworm-slim
# ---- deps: install all dependencies (native modules compiled/downloaded here) ----
FROM node:${NODE_VERSION} AS deps
WORKDIR /app
RUN apt-get update \
&& apt-get install -y --no-install-recommends python3 make g++ ca-certificates \
&& rm -rf /var/lib/apt/lists/*
COPY package.json package-lock.json ./
RUN npm ci
# ---- builder: compile the Next.js app to standalone output ----
FROM node:${NODE_VERSION} AS builder
WORKDIR /app
ENV NEXT_TELEMETRY_DISABLED=1
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN npm run build
# ---- runner: minimal production runtime ----
FROM node:${NODE_VERSION} AS runner
WORKDIR /app
ENV NODE_ENV=production \
NEXT_TELEMETRY_DISABLED=1 \
PORT=3000 \
HOSTNAME=0.0.0.0
# Run as an unprivileged user.
RUN groupadd --gid 1001 nodejs \
&& useradd --uid 1001 --gid nodejs --no-create-home --shell /usr/sbin/nologin nextjs
# Standalone server + the assets it does not inline (static chunks).
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
# Writable, persistable data directory (SQLite DB, SCORM extracts, uploads).
RUN mkdir -p /app/data && chown -R nextjs:nodejs /app/data
VOLUME ["/app/data"]
USER nextjs
EXPOSE 3000
# Liveness probe against a lightweight page (Node 20 has global fetch).
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \
CMD node -e "fetch('http://127.0.0.1:'+(process.env.PORT||3000)+'/login').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))"
CMD ["node", "server.js"]