fix(server): Docker build when prisma postinstall runs
Copy Prisma schema before npm ci in the builder image and skip postinstall in the production stage since the client is copied from builder. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+4
-7
@@ -3,16 +3,13 @@ FROM node:20-alpine AS builder
|
|||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
RUN apk add --no-cache openssl libc6-compat
|
RUN apk add --no-cache openssl libc6-compat
|
||||||
|
|
||||||
# Copy package configurations
|
# Copy package configurations and Prisma schema (postinstall runs prisma generate)
|
||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
|
COPY prisma ./prisma
|
||||||
|
|
||||||
# Install all dependencies (including devDependencies for tsc)
|
# Install all dependencies (including devDependencies for tsc)
|
||||||
RUN npm ci
|
RUN npm ci
|
||||||
|
|
||||||
# Copy Prisma schema and generate Client code
|
|
||||||
COPY prisma ./prisma
|
|
||||||
RUN npx prisma generate
|
|
||||||
|
|
||||||
# Copy source and compile TypeScript
|
# Copy source and compile TypeScript
|
||||||
COPY src ./src
|
COPY src ./src
|
||||||
COPY tsconfig.json ./
|
COPY tsconfig.json ./
|
||||||
@@ -26,8 +23,8 @@ RUN apk add --no-cache openssl libc6-compat
|
|||||||
# Copy package configurations
|
# Copy package configurations
|
||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
|
|
||||||
# Install only production dependencies
|
# Install only production dependencies (Prisma client copied from builder; skip postinstall)
|
||||||
RUN npm ci --omit=dev
|
RUN npm ci --omit=dev --ignore-scripts
|
||||||
|
|
||||||
# Copy generated Prisma Client from builder stage
|
# Copy generated Prisma Client from builder stage
|
||||||
COPY --from=builder /app/node_modules/@prisma/client ./node_modules/@prisma/client
|
COPY --from=builder /app/node_modules/@prisma/client ./node_modules/@prisma/client
|
||||||
|
|||||||
Reference in New Issue
Block a user