Fix Prisma: force linux-musl-openssl-3.0.x binary + install openssl in runner

This commit is contained in:
2026-02-18 00:30:24 +00:00
parent 1eb718cea6
commit 3191823592

View File

@@ -4,16 +4,12 @@
FROM node:22-alpine AS base
# Install dependencies only when needed
FROM base AS deps
RUN apk add --no-cache libc6-compat python3 make g++
WORKDIR /app
# Copy package files - skip postinstall (prisma generate runs in builder stage)
COPY package*.json ./
RUN npm ci --legacy-peer-deps --ignore-scripts
# Rebuild the source code only when needed
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
@@ -21,17 +17,18 @@ COPY . .
ENV NEXT_TELEMETRY_DISABLED=1
ENV NODE_ENV=production
# Force Prisma to generate linux-musl-openssl-3.0.x binary (Alpine 3.21 uses OpenSSL 3.x)
ENV PRISMA_CLI_BINARY_TARGETS=linux-musl-openssl-3.0.x
# Generate Prisma Client (schema is available from COPY . .)
RUN npx prisma generate
# Build the application
RUN npm run build
# Production image
FROM base AS runner
WORKDIR /app
# Install OpenSSL 3.x so Prisma can load its query engine
RUN apk add --no-cache openssl
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
@@ -49,7 +46,6 @@ COPY --from=builder /app/prisma ./prisma
USER nextjs
EXPOSE 3000
ENV PORT=3000
ENV HOSTNAME="0.0.0.0"