# nibe_datamanager/nibedatamanager_fe/Dockerfile — the nibe data-manager Angular SPA.
FROM public.ecr.aws/docker/library/node:20-alpine AS build
WORKDIR /app
COPY package*.json ./
# angular-tabler-icons@3.26.0 declares a stale peer range (@angular/common "17 - 19") while
# this app is on Angular 21.2, so a strict `npm ci` fails ERESOLVE. The other SPAs in this
# repo need the same flag but for a different package (ngx-numeric-captcha), so this is not
# a copied incantation - verified by building without it first.
RUN npm ci --legacy-peer-deps
COPY . .

# The `docker` configuration sets baseHref=/nibe/ and swaps in environment.docker.ts, whose
# URLs are all root-relative. Do NOT pass an absolute --base-href here: it bakes a hostname
# into the bundle and forces a rebuild per environment.
RUN npx ng build --configuration=docker

FROM public.ecr.aws/docker/library/nginx:alpine
# This project uses the legacy @angular-devkit/build-angular:browser builder, which writes
# straight to outputPath — there is no browser/ subdirectory here, unlike b2g_website which
# uses @angular/build:application and needs dist/<name>/browser.
COPY --from=build /app/dist/datamanager /usr/share/nginx/html
COPY docker/nginx-spa.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
