fix: add build tools and copy node_modules from builder
- Install python3, make, g++ in builder for native module compilation - Copy node_modules from builder stage to avoid rebuild in production - Fixes usb package compilation error in node:20-alpine
This commit is contained in:
+6
-3
@@ -3,11 +3,14 @@ FROM node:20-alpine AS builder
|
|||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Install build tools for native modules
|
||||||
|
RUN apk add --no-cache python3 make g++
|
||||||
|
|
||||||
# Copy root package files for workspace install
|
# Copy root package files for workspace install
|
||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
COPY frontend/package*.json ./frontend/
|
COPY frontend/package*.json ./frontend/
|
||||||
|
|
||||||
# Install dependencies using npm install (no individual lockfile in workspace)
|
# Install dependencies
|
||||||
RUN npm install --legacy-peer-deps
|
RUN npm install --legacy-peer-deps
|
||||||
|
|
||||||
# Copy frontend source
|
# Copy frontend source
|
||||||
@@ -26,8 +29,8 @@ WORKDIR /app
|
|||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
COPY frontend/package*.json ./frontend/
|
COPY frontend/package*.json ./frontend/
|
||||||
|
|
||||||
# Install production dependencies
|
# Copy node_modules from builder (includes compiled native modules)
|
||||||
RUN npm install --legacy-peer-deps --omit=dev
|
COPY --from=builder /app/node_modules ./node_modules
|
||||||
|
|
||||||
# Copy built files from builder
|
# Copy built files from builder
|
||||||
COPY --from=builder /app/frontend/.next ./frontend/.next
|
COPY --from=builder /app/frontend/.next ./frontend/.next
|
||||||
|
|||||||
Reference in New Issue
Block a user