service-template-react/Dockerfile
nholtware 20b204da4d build: fail fast on stalled npm fetches in the image build
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 02:36:31 -06:00

18 lines
841 B
Docker

# Build stage: Vite -> static dist/. GIT_SHA is passed by the build-push action.
FROM node:22.23.4-alpine AS build
WORKDIR /app
COPY package.json package-lock.json ./
# Fail fast and retry on a stalled registry fetch (npm defaults can hang ~10 min).
RUN npm ci --fetch-timeout=60000 --fetch-retries=5 --fetch-retry-mintimeout=2000 --no-audit --no-fund
COPY . .
ARG GIT_SHA=dev
ENV VITE_GIT_SHA=${GIT_SHA}
RUN npx vite build
# Runtime stage: static files only, no Node. Runs as uid 101, listens on 8080.
FROM nginxinc/nginx-unprivileged:1.31.7-alpine
COPY nginx/default.conf /etc/nginx/conf.d/default.conf
COPY --chmod=0755 docker-entrypoint.d/10-config.sh /docker-entrypoint.d/10-config.sh
# html dir owned by nginx so 10-config.sh can write config.js at start.
COPY --from=build --chown=101:101 /app/dist /usr/share/nginx/html
EXPOSE 8080