Fix Docker build: Install dev dependencies for build process
🔧 Critical Fix: - Remove --only=production from client build stage (needs devDependencies) - Remove --only=production from server build stage (needs TypeScript, etc.) - Add production dependencies install in final stage only - Remove duplicate npm ci commands 🏗️ Build Process Fixed: - Client: npm ci (all deps) → build with TypeScript/Vite → copy dist/ - Server: npm ci (all deps) → build with TypeScript → copy dist/ - Production: Install only runtime dependencies for final image ⚡ Why This Fixes It: - Build tools (TypeScript, Vite) are devDependencies - --only=production excludes build tools, causing 'npm run build' to fail - Final production stage still gets minimal runtime dependencies This should resolve the 'npm run build exit code 127' Docker build error.
This commit is contained in:
parent
b0280ae9af
commit
db24455248
1 changed files with 9 additions and 5 deletions
14
Dockerfile
14
Dockerfile
|
|
@ -6,7 +6,7 @@ WORKDIR /app/client
|
||||||
|
|
||||||
# Copy client package files
|
# Copy client package files
|
||||||
COPY client/package*.json ./
|
COPY client/package*.json ./
|
||||||
RUN npm ci --only=production
|
RUN npm ci
|
||||||
|
|
||||||
# Copy client source and build
|
# Copy client source and build
|
||||||
COPY client/ ./
|
COPY client/ ./
|
||||||
|
|
@ -18,7 +18,7 @@ WORKDIR /app/server
|
||||||
|
|
||||||
# Copy server package files
|
# Copy server package files
|
||||||
COPY server/package*.json ./
|
COPY server/package*.json ./
|
||||||
RUN npm ci --only=production
|
RUN npm ci
|
||||||
|
|
||||||
# Copy server source and build
|
# Copy server source and build
|
||||||
COPY server/ ./
|
COPY server/ ./
|
||||||
|
|
@ -35,11 +35,15 @@ RUN apk add --no-cache dumb-init curl
|
||||||
RUN addgroup -g 1001 -S nodejs
|
RUN addgroup -g 1001 -S nodejs
|
||||||
RUN adduser -S nodejs -u 1001
|
RUN adduser -S nodejs -u 1001
|
||||||
|
|
||||||
# Copy built server
|
# Copy server package files for production dependencies
|
||||||
COPY --from=server-build --chown=nodejs:nodejs /app/server/dist ./server/
|
|
||||||
COPY --from=server-build --chown=nodejs:nodejs /app/server/node_modules ./server/node_modules/
|
|
||||||
COPY --from=server-build --chown=nodejs:nodejs /app/server/package*.json ./server/
|
COPY --from=server-build --chown=nodejs:nodejs /app/server/package*.json ./server/
|
||||||
|
|
||||||
|
# Install only production dependencies
|
||||||
|
RUN cd server && npm ci --only=production && cd ..
|
||||||
|
|
||||||
|
# Copy built server
|
||||||
|
COPY --from=server-build --chown=nodejs:nodejs /app/server/dist ./server/dist/
|
||||||
|
|
||||||
# Copy built client for nginx sharing
|
# Copy built client for nginx sharing
|
||||||
COPY --from=client-build --chown=nodejs:nodejs /app/client/dist ./client/dist/
|
COPY --from=client-build --chown=nodejs:nodejs /app/client/dist ./client/dist/
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue