# Standalone SPA image, used when the frontend is served separately from the
# API (the `frontend` service in docker-compose). nginx serves the static
# bundle and proxies /api to the backend so the session cookie stays
# first-party and CORS is not involved.

FROM node:22-alpine AS build

WORKDIR /build
COPY package.json package-lock.json* ./
RUN npm ci --no-audit --no-fund || npm install --no-audit --no-fund

COPY . ./
RUN npm run build

FROM nginx:1.27-alpine AS runtime

COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=build /build/dist /usr/share/nginx/html

EXPOSE 80

HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
    CMD wget -qO- http://127.0.0.1/ >/dev/null || exit 1
