FROM node:20-alpine AS builder WORKDIR /app COPY frontend/package*.json frontend/ # 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 --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/ RUN sh -c 'NODE_OPTIONS="--max_old_space_size=512" npm run build --prefix frontend' FROM nginx:stable-alpine COPY --from=builder /app/frontend/dist /usr/share/nginx/html COPY deploy/nginx/docker-chat.conf /etc/nginx/conf.d/default.conf EXPOSE 8443 CMD ["nginx", "-g", "daemon off;"]