Implement official Prisma solution for client generation
Following Prisma's official documentation for deployment caching issues: https://www.prisma.io/docs/orm/more/help-and-troubleshooting/vercel-caching-issue Changes: - Add 'prisma generate' to build script (official Prisma recommendation) - Add postinstall script for automatic client generation - Remove custom stub generator workaround - Keep runtime Prisma client generation in entrypoint.sh for reliability - Add openssl to runtime container (required for Prisma engines) This follows Prisma best practices: explicitly run prisma generate during the build process to ensure Prisma Client is always up-to-date. The entrypoint script regenerates the client at runtime to guarantee engine availability in the production environment.
This commit is contained in:
@@ -21,7 +21,8 @@ ENV DATABASE_PATH=/tmp/build.db
|
||||
ENV DATABASE_URL=file:/tmp/build.db
|
||||
COPY --from=deps /app/node_modules ./node_modules
|
||||
COPY . .
|
||||
RUN npx prisma generate
|
||||
# Build the application (includes prisma generate as per Prisma best practices)
|
||||
# Real Prisma client will be regenerated at runtime to ensure engine availability
|
||||
RUN npx prisma db push --skip-generate
|
||||
RUN npm run build && rm -f /tmp/build.db
|
||||
|
||||
@@ -30,8 +31,11 @@ ENV NODE_ENV=production
|
||||
ENV PORT=3000
|
||||
WORKDIR /app
|
||||
|
||||
# Install gosu for privilege dropping
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends gosu && rm -rf /var/lib/apt/lists/*
|
||||
# Install gosu for privilege dropping and openssl for Prisma
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
gosu \
|
||||
openssl \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN groupadd -g 1001 nodejs && useradd -r -u 1001 -g nodejs nextjs
|
||||
|
||||
|
||||
Reference in New Issue
Block a user