perf(deploy): reduce memory/IO during npm install/build for small VMs (NODE_OPTIONS, npm flags)
This commit is contained in:
@@ -2,9 +2,9 @@ FROM node:20-alpine AS builder
|
|||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY backend/package*.json backend/
|
COPY backend/package*.json backend/
|
||||||
# Install all dependencies (including dev) in builder so tools like tsc are available for build
|
# Install all dependencies (including dev) in builder so tools like tsc are available for build
|
||||||
RUN sh -c 'if [ -f backend/package-lock.json ] || [ -f backend/npm-shrinkwrap.json ]; then npm ci --prefix backend; else npm install --prefix backend; fi'
|
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/
|
COPY backend/ backend/
|
||||||
RUN npm run build --prefix backend
|
RUN sh -c 'NODE_OPTIONS="--max_old_space_size=512" npm run build --prefix backend'
|
||||||
|
|
||||||
FROM node:20-alpine
|
FROM node:20-alpine
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
@@ -2,9 +2,9 @@ FROM node:20-alpine AS builder
|
|||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY frontend/package*.json frontend/
|
COPY frontend/package*.json frontend/
|
||||||
# Use npm ci when lockfile exists in frontend, fallback to npm install
|
# Use npm ci when lockfile exists in frontend, fallback to npm install
|
||||||
RUN sh -c 'if [ -f frontend/package-lock.json ] || [ -f frontend/npm-shrinkwrap.json ]; then npm ci --prefix frontend; else npm install --prefix frontend; fi'
|
RUN sh -c 'if [ -f frontend/package-lock.json ] || [ -f frontend/npm-shrinkwrap.json ]; then npm ci --prefix frontend --no-audit --no-fund --prefer-offline --no-progress; else npm install --prefix frontend --no-audit --no-fund --prefer-offline --no-progress; fi'
|
||||||
COPY frontend/ frontend/
|
COPY frontend/ frontend/
|
||||||
RUN npm run build --prefix frontend
|
RUN sh -c 'NODE_OPTIONS="--max_old_space_size=512" npm run build --prefix frontend'
|
||||||
|
|
||||||
FROM nginx:stable-alpine
|
FROM nginx:stable-alpine
|
||||||
COPY --from=builder /app/frontend/dist /usr/share/nginx/html
|
COPY --from=builder /app/frontend/dist /usr/share/nginx/html
|
||||||
|
Reference in New Issue
Block a user