Phones kept running old JS because their cached index.html pointed at an old hashed asset. Both images now bake the commit SHA as BUILD_VERSION; the backend exposes it at GET /api/version and the client reloads once with a cache-busting query when its own baked version differs. Guarded by sessionStorage so it cannot loop. /api/version is unauthenticated like /api/health.
23 lines
624 B
Docker
23 lines
624 B
Docker
FROM node:22-alpine AS build
|
|
|
|
# Same value as the backend's BUILD_VERSION so the client can compare them.
|
|
ARG BUILD_VERSION=unknown
|
|
ENV VITE_BUILD_VERSION=${BUILD_VERSION}
|
|
|
|
WORKDIR /app
|
|
COPY package.json package-lock.json ./
|
|
RUN npm ci --no-audit --no-fund
|
|
COPY . .
|
|
RUN npm run build
|
|
|
|
FROM nginx:alpine
|
|
|
|
# Defaults; override at runtime. The nginx entrypoint runs envsubst over
|
|
# /etc/nginx/templates/*.template, so only these referenced vars are replaced.
|
|
ENV API_TOKEN_HEADER=X-API-Token
|
|
ENV API_TOKEN=
|
|
|
|
COPY --from=build /app/dist /usr/share/nginx/html
|
|
COPY nginx.conf /etc/nginx/templates/default.conf.template
|
|
EXPOSE 80
|