Fix Prisma engine generation by copying schema before npm install
The previous attempt failed because Prisma CLI couldn't parse the binaryTarget configuration due to an incorrect environment variable I set. This commit: - Removes the non-existent PRISMA_CLI_BINARY_TARGETS environment variable - Copies the Prisma schema BEFORE running npm ci, allowing the postinstall script to properly generate the Prisma client with engines - Adds openssl and ca-certificates to deps stage for engine downloads - Simplifies the builder stage to rely on pre-generated engines from deps This ensures Prisma engines are downloaded during npm installation via the postinstall hook, making them available for subsequent build steps.
This commit is contained in:
@@ -12,14 +12,10 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
openssl \
|
||||
ca-certificates \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
# Set Prisma to download engines during install and ignore checksum errors
|
||||
ENV PRISMA_CLI_BINARY_TARGETS=native,debian-openssl-3.0.x
|
||||
ENV PRISMA_ENGINES_CHECKSUM_IGNORE_MISSING=1
|
||||
COPY package.json package-lock.json* ./
|
||||
RUN if [ -f package-lock.json ]; then npm ci; else npm install; fi
|
||||
# Explicitly generate Prisma client with engines during deps stage
|
||||
# Copy prisma schema before npm ci so postinstall can generate if needed
|
||||
COPY prisma ./prisma
|
||||
RUN npx prisma generate
|
||||
RUN if [ -f package-lock.json ]; then npm ci; else npm install; fi
|
||||
|
||||
FROM base AS builder
|
||||
ENV NODE_ENV=production
|
||||
@@ -27,9 +23,6 @@ ENV NEXT_TELEMETRY_DISABLED=1
|
||||
# Set a temporary database path for build
|
||||
ENV DATABASE_PATH=/tmp/build.db
|
||||
ENV DATABASE_URL=file:/tmp/build.db
|
||||
# Skip Prisma engine checksum validation and downloads (engines already bundled from deps stage)
|
||||
ENV PRISMA_ENGINES_CHECKSUM_IGNORE_MISSING=1
|
||||
ENV PRISMA_SKIP_POSTINSTALL_GENERATE=1
|
||||
# Install openssl for Prisma query engine
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
openssl \
|
||||
@@ -37,6 +30,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
COPY --from=deps /app/node_modules ./node_modules
|
||||
COPY . .
|
||||
# Build the application (prisma client already generated in deps stage with engines)
|
||||
# Use db push to create schema without regenerating client
|
||||
RUN npx prisma db push --skip-generate
|
||||
RUN npm run build && rm -f /tmp/build.db
|
||||
|
||||
|
||||
Reference in New Issue
Block a user