# ---------- Build stage ---------- # glibc (Debian) base: the lockfile's native binaries (@rollup/rollup-linux-x64-gnu, # @esbuild/linux-x64) are built against glibc. alpine uses musl and would fail to load them. FROM node:22-slim AS build WORKDIR /app # Install dependencies first (better layer caching) COPY package.json package-lock.json ./ COPY apps/web/package.json apps/web/package.json # --include=optional installs the platform-native Rollup/esbuild binaries Vite needs. # Never use --no-optional / --omit=optional here: it omits @rollup/rollup-linux-x64-gnu # and the Vite build crashes with "Cannot find module @rollup/rollup-linux-x64-gnu". RUN npm ci --include=optional # Copy source and build the static site COPY apps/web apps/web RUN npm run build --workspace apps/web # ---------- Production stage ---------- FROM nginx:stable-alpine COPY nginx.conf /etc/nginx/conf.d/default.conf COPY --from=build /app/dist/apps/web /usr/share/nginx/html EXPOSE 80 CMD ["nginx", "-g", "daemon off;"]