From 04a42c903bad4bc7a6fdc2d96fa50c80d5f2d262 Mon Sep 17 00:00:00 2001 From: David Gwilliam Date: Sun, 29 Mar 2026 21:48:44 -0700 Subject: [PATCH] fix: ensure Prisma client generation and migrations in Docker build - Add explicit step in both builder and runner stages - Set DATABASE_URL environment variable for Prisma operations during build - Run database migrations during build to support static page generation - Copy package-lock.json to runner stage for production dependency installation - Fix the original TypeScript error: Module '@prisma/client' has no exported member 'Event' --- Dockerfile | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index e4e1350..4c69243 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,8 +18,14 @@ RUN npm ci # Copy source code COPY . . -# Build the application -RUN npm run build +# Generate Prisma client (with dummy DATABASE_URL for build-time generation) +RUN DATABASE_URL="file:./prisma/dev.db" npx prisma generate + +# Run database migrations (with dummy DATABASE_URL for build-time) +RUN DATABASE_URL="file:./prisma/dev.db" npx prisma migrate deploy + +# Build the application (with dummy DATABASE_URL for static page generation) +RUN DATABASE_URL="file:./prisma/dev.db" npm run build # Stage 2: Runner FROM node:20-alpine AS runner @@ -38,11 +44,16 @@ WORKDIR /app COPY --from=builder --chown=euchre:euchre /app/.next ./.next COPY --from=builder --chown=euchre:euchre /app/public ./public COPY --from=builder --chown=euchre:euchre /app/package.json ./package.json +COPY --from=builder --chown=euchre:euchre /app/package-lock.json ./package-lock.json COPY --from=builder --chown=euchre:euchre /app/prisma ./prisma # Install only production dependencies RUN npm ci --omit=dev +# Generate Prisma client +# Note: We need to set DATABASE_URL even for generation because prisma.config.ts requires it +RUN DATABASE_URL="file:./prisma/dev.db" npx prisma generate + # Switch to non-root user USER euchre