SQLite has no Prisma enums, so removing the enum blocks also dropped the enum
*objects* the app imports from @prisma/client (LinkType.DOCUMENT_LINK, etc.),
crashing Next.js prerender ("Cannot read properties of undefined"). A
build-time step (after `prisma generate`) re-injects the 18 enum objects into
the generated client, so no app files change. Verified: local `next build`
now prerenders all 90 pages.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
54 lines
2.2 KiB
Docker
54 lines
2.2 KiB
Docker
FROM ghcr.io/hanzoai/nodejs:v24.18.0 AS base
|
|
RUN apk add --no-cache libc6-compat openssl python3 make g++
|
|
|
|
FROM base AS deps
|
|
WORKDIR /app
|
|
COPY package.json package-lock.json ./
|
|
COPY prisma ./prisma
|
|
ENV HUSKY=0
|
|
RUN npm install --legacy-peer-deps
|
|
|
|
FROM base AS builder
|
|
WORKDIR /app
|
|
COPY --from=deps /app/node_modules ./node_modules
|
|
COPY . .
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
ENV DOCKER_OUTPUT=1
|
|
# Dummy env vars to prevent module-scope crashes during Next.js build
|
|
# (OpenAI, Hanko, etc. initialize clients at import time)
|
|
ENV OPENAI_API_KEY=build-placeholder
|
|
ENV HANKO_API_KEY=build-placeholder
|
|
ENV NEXT_PUBLIC_HANKO_TENANT_ID=build-placeholder
|
|
RUN npx prisma generate
|
|
# SQLite has no Prisma enums; re-inject the enum objects the app imports from
|
|
# @prisma/client (e.g. LinkType.DOCUMENT_LINK) so runtime/prerender resolves them.
|
|
RUN node prisma/inject-sqlite-enums.cjs
|
|
ENV NODE_OPTIONS="--max-old-space-size=4096"
|
|
RUN npm run build
|
|
|
|
FROM ghcr.io/hanzoai/nodejs:v24.18.0 AS runner
|
|
RUN apk add --no-cache openssl
|
|
WORKDIR /app
|
|
ENV NODE_ENV=production
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
RUN addgroup --system --gid 1001 nodejs
|
|
RUN adduser --system --uid 1001 nextjs
|
|
COPY --from=builder /app/public ./public
|
|
RUN mkdir .next
|
|
RUN chown nextjs:nodejs .next
|
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
|
COPY --from=builder --chown=nextjs:nodejs /app/prisma ./prisma
|
|
RUN ln -s /app/prisma/migrations /app/prisma/schema/migrations
|
|
COPY --from=builder --chown=nextjs:nodejs /app/node_modules/.prisma ./node_modules/.prisma
|
|
COPY --from=builder --chown=nextjs:nodejs /app/node_modules/@prisma ./node_modules/@prisma
|
|
COPY --from=builder --chown=nextjs:nodejs /app/node_modules/prisma ./node_modules/prisma
|
|
COPY --from=builder --chown=nextjs:nodejs /app/node_modules/.bin ./node_modules/.bin
|
|
USER nextjs
|
|
EXPOSE 3000
|
|
ENV PORT=3000
|
|
# SQLite: reconcile schema on startup via `db push` (Prisma has no migrate-deploy
|
|
# path for the sqlite provider here; the pg migration history under prisma/migrations
|
|
# is postgres-specific and unused). Schema folder = prismaSchemaFolder preview.
|
|
CMD ["sh", "-c", "node_modules/.bin/prisma db push --schema prisma/schema --skip-generate --accept-data-loss && node server.js"]
|