# J621-Frontend — builds the SPA and serves it as static files.
#
# Build context is the repository root, e.g.:
#   docker build -f deploy/J621-Frontend -t j621-frontend .
#
# This container only serves the SPA (with the index fallback). The public
# entry point is the separate "nginx" reverse-proxy service in the compose
# files, so API routing stays in one place.

# syntax=docker/dockerfile:1

FROM node:22-alpine AS build
ARG GIT_HASH=dev
ENV GIT_HASH=$GIT_HASH
WORKDIR /app
COPY frontend/package.json frontend/package-lock.json ./
RUN npm ci --no-audit --no-fund
COPY frontend/ ./
RUN npm run build

FROM nginx:1.29-alpine
COPY deploy/nginx-frontend.conf /etc/nginx/conf.d/default.conf
COPY --from=build /app/dist /usr/share/nginx/html
EXPOSE 80
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s \
    CMD wget -q --spider http://127.0.0.1/nginx-health || exit 1
