# syntax=docker/dockerfile:1
# Management UI: build the Vue SPA, serve it with nginx and proxy /api
# to the api service (API_UPSTREAM, default api:8000). Kept as its own
# image/container - the api stays a pure JSON API.

FROM node:22-alpine AS build
WORKDIR /app
# No lockfile is committed yet, so install (not ci). After the first local
# `npm install` a package-lock.json is generated and should be committed.
COPY package.json ./
RUN npm install
COPY . .
RUN npm run build

FROM nginx:1.27-alpine
# The official nginx image envsubst-processes /etc/nginx/templates/*.template
# into /etc/nginx/conf.d on container start.
ENV API_UPSTREAM=api:8000
COPY nginx.conf.template /etc/nginx/templates/default.conf.template
COPY --from=build /app/dist /usr/share/nginx/html
EXPOSE 80