# Stage 1: build # Use the native build platform so npm ci never runs under QEMU emulation. # The build output (static HTML/JS/CSS) is platform-independent. # node:20-slim (Debian/glibc) avoids lightningcss musl binary resolution issues on Alpine. FROM --platform=$BUILDPLATFORM node:20-slim AS builder ARG VITE_STANDALONE=false ENV VITE_STANDALONE=$VITE_STANDALONE WORKDIR /app COPY frontend/package*.json ./ RUN npm ci COPY frontend/ . COPY VERSION ../VERSION RUN npm run build # Stage 2: serve FROM nginx:alpine COPY --from=builder /app/dist /usr/share/nginx/html # Nginx config: use standalone config (no backend proxy) or full config ARG VITE_STANDALONE=false COPY docker/nginx.conf /etc/nginx/conf.d/default.conf COPY docker/nginx.standalone.conf /etc/nginx/conf.d/nginx.standalone.conf RUN if [ "$VITE_STANDALONE" = "true" ]; then \ cp /etc/nginx/conf.d/nginx.standalone.conf /etc/nginx/conf.d/default.conf; \ fi && \ rm /etc/nginx/conf.d/nginx.standalone.conf EXPOSE 80