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