# ---- build ----
FROM node:22-alpine AS build
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci --legacy-peer-deps
COPY . .
# Kendo Angular license: passed in as a build-arg (from a Gitea Actions secret).
# kendo-licensing v20 needs the key activated at build time. We both export the
# env var AND run `kendo-ui-license activate`, which validates the key and writes
# the activation kendo-licensing reads during `ng build`. None of this reaches
# the runtime image (that stage is just nginx + static files).
ARG KENDO_UI_LICENSE
ENV KENDO_UI_LICENSE=${KENDO_UI_LICENSE}
RUN npx kendo-ui-license activate
RUN npm run build           # -> dist/client-bridge/browser  (production by default)

# ---- runtime ----
FROM nginx:alpine AS final
COPY nginx.app.conf /etc/nginx/conf.d/default.conf
COPY --from=build /app/dist/client-bridge/browser /usr/share/nginx/html
EXPOSE 80
