fix: enable build scripts for bcrypt and prisma native modules
- Add build dependencies (python3, make, g++) to both builder and production stages - Use --ignore-scripts=false flag to ensure native modules compile - Fixes MODULE_NOT_FOUND error for bcrypt_lib.node
This commit is contained in:
parent
058a388f4c
commit
8c495f3871
1 changed files with 12 additions and 5 deletions
|
|
@ -3,12 +3,16 @@ FROM node:20-alpine AS builder
|
|||
|
||||
WORKDIR /app
|
||||
|
||||
# Install build dependencies for native modules (bcrypt, prisma)
|
||||
RUN apk add --no-cache python3 make g++
|
||||
|
||||
# Copy package files
|
||||
COPY package*.json ./
|
||||
COPY pnpm-lock.yaml* ./
|
||||
|
||||
# Install pnpm and dependencies
|
||||
RUN npm install -g pnpm && pnpm install --frozen-lockfile
|
||||
# Install pnpm and dependencies with build scripts enabled
|
||||
RUN npm install -g pnpm && \
|
||||
pnpm install --frozen-lockfile --ignore-scripts=false
|
||||
|
||||
# Copy source code
|
||||
COPY . .
|
||||
|
|
@ -24,6 +28,9 @@ FROM node:20-alpine AS production
|
|||
|
||||
WORKDIR /app
|
||||
|
||||
# Install build dependencies for native modules (bcrypt, prisma)
|
||||
RUN apk add --no-cache python3 make g++
|
||||
|
||||
# Install pnpm
|
||||
RUN npm install -g pnpm
|
||||
|
||||
|
|
@ -31,14 +38,14 @@ RUN npm install -g pnpm
|
|||
COPY package*.json ./
|
||||
COPY pnpm-lock.yaml* ./
|
||||
|
||||
# Install production dependencies and prisma for generate
|
||||
RUN pnpm install --frozen-lockfile
|
||||
# Install production dependencies with build scripts enabled
|
||||
RUN pnpm install --frozen-lockfile --ignore-scripts=false
|
||||
|
||||
# Copy prisma schema and generate client
|
||||
COPY --from=builder /app/prisma ./prisma
|
||||
RUN pnpm prisma:generate
|
||||
|
||||
# Remove devDependencies
|
||||
# Remove devDependencies (keep bcrypt and prisma client)
|
||||
RUN pnpm prune --prod
|
||||
|
||||
# Copy built files from builder
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue