fix: enable build scripts for bcrypt and prisma native modules
All checks were successful
Build and Deploy Backend / Build Backend Docker Image (push) Successful in 45s
Build and Deploy Backend / Deploy E-learning Backend to Dev Server (push) Successful in 2s
Build and Deploy Backend / Notify Deployment Status (push) Successful in 2s

- 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:
JakkrapartXD 2026-02-10 13:07:47 +07:00
parent 058a388f4c
commit 8c495f3871

View file

@ -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