# Build stage. Node 22 (glibc) so nothing here depends on the host.
FROM node:22-slim AS build
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
COPY . .
# The build's own name, shown at the foot of the studio's tab rail (vite.config
# reads it): `docker compose build frontend --build-arg
# VERSION=$(git rev-parse --short HEAD)` puts the commit in the page, which is
# how the image on the NAS says which revision it is. Left unset, the build
# stamps its own time.
ARG VERSION=
# tsc --noEmit && vite build; the prebuild hook copies canvaskit.wasm into public/
RUN npm run build

# Runtime: static files only. The photo pipeline runs in the visitor's browser.
FROM nginx:1.27-alpine
COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=build /app/dist /usr/share/nginx/html
EXPOSE 80
