- Remove Microsoft Entra ID SSO entirely; local admin credentials login is the only sign-in path (fail-closed on empty LOCAL_ADMIN_PASSWORD). Delete config/users.json allowlist and lookupRole. - Move CI from .github to .gitea/workflows (Gitea Actions, runner label gitea-runner); drop the k8s-API network debug step. - Replace JFrog with local Harbor: push/pull via host.docker.internal:8080/library, login with HARBOR_* Gitea secrets, pull secret renamed to harbor-pull-secret (created by CI per namespace). - Adapt Helm values to Docker Desktop k8s: storageClassName hostpath, Harbor image repositories, *.local ingress hosts, AUTH_URL scheme http (configurable via ingress.scheme). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
85 lines
3.2 KiB
Docker
85 lines
3.2 KiB
Docker
# syntax=docker/dockerfile:1
|
|
#
|
|
# Next.js 15 (standalone) + Prisma server image for the IT Cost Dashboard.
|
|
#
|
|
# Debian slim, NOT Alpine: better-sqlite3 (a devDependency native addon) ships
|
|
# glibc prebuilds and would otherwise compile from source, and Prisma's query
|
|
# engine needs the musl-specific binaryTarget on Alpine. ~40 MB more for two
|
|
# fewer traps.
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Stage 1: deps — install node_modules once, including native addons.
|
|
# ---------------------------------------------------------------------------
|
|
FROM node:20-bookworm-slim AS deps
|
|
WORKDIR /app
|
|
|
|
# python3/make/g++ are the better-sqlite3 source-build fallback; openssl is what
|
|
# the Prisma postinstall links its query engine against. All discarded with this
|
|
# stage.
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
openssl ca-certificates python3 make g++ \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
COPY package.json package-lock.json ./
|
|
# No --ignore-scripts: Prisma's postinstall is what unpacks the query engine.
|
|
RUN npm ci
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Stage 2: builder — prisma generate (prod/mysql schema) + next build.
|
|
# ---------------------------------------------------------------------------
|
|
FROM node:20-bookworm-slim AS builder
|
|
WORKDIR /app
|
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
openssl ca-certificates \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
COPY --from=deps /app/node_modules ./node_modules
|
|
COPY . .
|
|
|
|
# Auth.js v5 constructs NextAuth() at module init (src/auth.ts), which can throw
|
|
# without a secret while pre-rendering. This placeholder is build-time only —
|
|
# the real AUTH_SECRET arrives at runtime from the k8s Secret.
|
|
ARG AUTH_SECRET=build-placeholder-not-used-at-runtime
|
|
ENV AUTH_SECRET=${AUTH_SECRET}
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
ENV NODE_ENV=production
|
|
|
|
# No DATABASE_URL needed: every page is "use client" and fetches /api/* at
|
|
# runtime, and `await auth()` in the layout returns null harmlessly.
|
|
# build:prod == prisma generate --schema=prisma/prod/schema.prisma && next build
|
|
RUN npm run build:prod
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Stage 3: runner — standalone output only, non-root.
|
|
# ---------------------------------------------------------------------------
|
|
FROM node:20-bookworm-slim AS runner
|
|
WORKDIR /app
|
|
|
|
# openssl is required at runtime: the Prisma query engine links against it.
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
openssl ca-certificates \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
RUN groupadd --system --gid 1001 nodejs \
|
|
&& useradd --system --uid 1001 --gid nodejs nextjs
|
|
|
|
# .next/standalone ships its own traced node_modules — do NOT copy the
|
|
# builder's. .next/static is NOT part of standalone and must come separately or
|
|
# every CSS/JS chunk 404s.
|
|
# NOTE: this repo has no public/ directory; adding a COPY for it would fail.
|
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
|
|
|
USER nextjs
|
|
|
|
ENV HOSTNAME=0.0.0.0
|
|
ENV PORT=3000
|
|
ENV NODE_ENV=production
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
|
|
EXPOSE 3000
|
|
|
|
# Standalone replaces `next start`.
|
|
CMD ["node", "server.js"]
|