fix: copy node_modules from builder to avoid sharp recompilation

This commit is contained in:
Manus Deploy
2026-04-28 12:28:18 -04:00
parent cdd8aabf39
commit 8bf2001693

View File

@@ -24,7 +24,7 @@ RUN npm install -g pnpm@10.4.1 node-gyp
COPY package.json pnpm-lock.yaml ./ COPY package.json pnpm-lock.yaml ./
COPY patches/ ./patches/ COPY patches/ ./patches/
# Install dependencies (with node-gyp available) # Install ALL dependencies (including devDeps for build)
RUN pnpm install --frozen-lockfile RUN pnpm install --frozen-lockfile
# Copy source code # Copy source code
@@ -38,7 +38,7 @@ RUN pnpm build
# ============================================================ # ============================================================
FROM node:22-alpine AS production FROM node:22-alpine AS production
# Install runtime dependencies # Install runtime dependencies only (vips for sharp, poppler for PDF)
RUN apk add --no-cache \ RUN apk add --no-cache \
poppler-utils \ poppler-utils \
vips \ vips \
@@ -46,23 +46,16 @@ RUN apk add --no-cache \
WORKDIR /app WORKDIR /app
# Install pnpm # Copy node_modules from builder (already compiled, including sharp native binaries)
RUN npm install -g pnpm@10.4.1 COPY --from=builder /app/node_modules ./node_modules
# Copy package files
COPY package.json pnpm-lock.yaml ./
COPY patches/ ./patches/
# Install production dependencies only (no build tools needed for prod deps)
RUN apk add --no-cache python3 make g++ gcc libc-dev vips-dev pkgconfig && \
npm install -g node-gyp && \
pnpm install --frozen-lockfile --prod && \
apk del make g++ gcc libc-dev pkgconfig
# Copy built assets from builder # Copy built assets from builder
COPY --from=builder /app/dist ./dist COPY --from=builder /app/dist ./dist
COPY --from=builder /app/client/dist ./client/dist COPY --from=builder /app/client/dist ./client/dist
# Copy package.json (needed for module resolution)
COPY package.json ./
# Copy drizzle migrations # Copy drizzle migrations
COPY drizzle/ ./drizzle/ COPY drizzle/ ./drizzle/
COPY drizzle.config.ts ./ COPY drizzle.config.ts ./