From 8c495f38719ba28cbbb83e4dfa67e86ff0c01351 Mon Sep 17 00:00:00 2001 From: JakkrapartXD Date: Tue, 10 Feb 2026 13:07:47 +0700 Subject: [PATCH] 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 --- Backend/Dockerfile | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/Backend/Dockerfile b/Backend/Dockerfile index 2f262efb..b959e271 100644 --- a/Backend/Dockerfile +++ b/Backend/Dockerfile @@ -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