fix(deploy): copy pruned node_modules from builder to runtime instead of reinstalling
This commit is contained in:
@@ -5,11 +5,14 @@ COPY backend/package*.json backend/
|
||||
RUN sh -c 'if [ -f backend/package-lock.json ] || [ -f backend/npm-shrinkwrap.json ]; then npm ci --prefix backend --no-audit --no-fund --prefer-offline --no-progress; else npm install --prefix backend --no-audit --no-fund --prefer-offline --no-progress; fi'
|
||||
COPY backend/ backend/
|
||||
RUN sh -c 'NODE_OPTIONS="--max_old_space_size=512" npm run build --prefix backend'
|
||||
## Prune dev dependencies to shrink runtime layer
|
||||
RUN npm prune --omit=dev --prefix backend && rm -rf /root/.npm /tmp/*
|
||||
|
||||
FROM node:20-alpine
|
||||
WORKDIR /app
|
||||
ENV NODE_ENV=production
|
||||
COPY --from=builder /app/backend/dist ./dist
|
||||
COPY --from=builder /app/backend/node_modules ./node_modules
|
||||
COPY backend/package*.json ./
|
||||
RUN npm ci --production --prefix /app
|
||||
EXPOSE 4000
|
||||
CMD ["node", "./dist/index.js"]
|
||||
|
Reference in New Issue
Block a user