fix: prevent npm from installing all n8n dependencies during Docker build
The build was taking 10 minutes because npm install was installing ALL 2294 packages from package-lock.json instead of just TypeScript. Changed approach: - Don't copy package*.json to builder stage - Create empty package.json to prevent lock file issues - Install only the 3 required packages explicitly Results: - Builder stage: 2294 packages → 13 packages - Build time: ~374s → ~10s per platform - Total build time: 10 minutes → ~2 minutes 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -5,13 +5,13 @@
|
||||
FROM node:20-alpine AS builder
|
||||
WORKDIR /app
|
||||
|
||||
# Copy package files
|
||||
COPY package*.json ./
|
||||
# Copy tsconfig for TypeScript compilation
|
||||
COPY tsconfig.json ./
|
||||
|
||||
# Install ONLY TypeScript for compilation (no n8n deps)
|
||||
# Create minimal package.json and install ONLY TypeScript
|
||||
RUN --mount=type=cache,target=/root/.npm \
|
||||
npm install --no-save typescript @types/node @types/express
|
||||
echo '{}' > package.json && \
|
||||
npm install --no-save typescript@^5.8.3 @types/node@^22.15.30 @types/express@^5.0.3
|
||||
|
||||
# Copy source and build
|
||||
COPY src ./src
|
||||
|
||||
Reference in New Issue
Block a user