# ---- Build stage ---- FROM node:22-alpine AS build WORKDIR /app # Safety valve for the 2 GB host: without a cap a runaway build can exhaust the # server's RAM and take down neighbouring containers. Measured peak for this app # is ~550 MB, so 1 GB leaves headroom while still failing the build rather than # the server. Raise this only if the host gets more RAM. ENV NODE_OPTIONS=--max-old-space-size=1024 # Install deps from the lockfile first so this layer is reused when only src changes COPY package.json package-lock.json ./ RUN npm ci --no-audit --no-fund COPY . . RUN npm run build # ---- Runtime stage ---- FROM nginx:alpine # Remove Nginx's default "Welcome" page files completely RUN rm -rf /usr/share/nginx/html/* # Only the compiled assets reach the final image — no node_modules, no source COPY --from=build /app/dist /usr/share/nginx/html COPY nginx.conf /etc/nginx/nginx.conf EXPOSE 80 3000 CMD ["nginx", "-g", "daemon off;"]