# syntax=docker/dockerfile:1
#
# Two-stage build: compile the Svelte SPA with Vite, then serve the static
# bundle from a tiny nginx. The main serving-stack nginx reverse-proxies
# /kiosk/ to this container (see ../docker-compose.yml + ../http/default.conf),
# so this image only needs to serve the built assets at its own root.

# ---- build stage ----
FROM harbor.bitasylum.org/dockerhub/library/node:22-alpine AS build
WORKDIR /app

# Install deps first for layer caching. package-lock.json is committed, so use
# `npm ci` for a reproducible, lockfile-exact install.
COPY package.json package-lock.json ./
RUN npm ci

COPY . .
RUN npm run build        # -> /app/dist (base path /kiosk/)

# ---- serve stage ----
FROM harbor.bitasylum.org/dockerhub/library/nginx:stable-alpine
COPY nginx.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 -qO- http://127.0.0.1/ >/dev/null 2>&1 || exit 1
