# `npm run build` shells out to `dotnet fable` before `vite build`, so this
# stage needs both Node and the .NET SDK — simplest to install Node into the
# SDK image and run the existing script unmodified, rather than hand-split it.
# Build context is the repo root (see docker-compose.yml).
# Uses the SDK 10 image (not 9, even though the project targets net9.0):
# the NuGet client in SDK 9.0.x fails to restore the `fable` dotnet-tool
# package ("Settings file 'DotnetToolSettings.xml' was not found in the
# package", right after signature verification succeeds) — SDK 10's newer
# NuGet client reads the same package fine, and building a net9.0 project
# with a newer SDK is otherwise unaffected.
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
WORKDIR /src
RUN apt-get update && apt-get install -y --no-install-recommends nodejs npm && rm -rf /var/lib/apt/lists/*
COPY package.json package-lock.json ./
COPY .config/ .config/
RUN npm ci && dotnet tool restore
COPY src/Domain/ src/Domain/
COPY src/Client/ src/Client/
COPY vite.config.js ./
RUN npm run build

FROM nginx:1.27-alpine AS runtime
COPY --from=build /src/src/Client/dist /usr/share/nginx/html
COPY src/Client/nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
