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'
This commit is contained in:
+13
-2
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user