# GNMON-001 section 6: Blazor Server dashboard image.
# Multi-stage build from the MCR .NET images (not Docker Hub, so server
# side rebuilds stay possible even under Docker Hub rate limits).
# Runs as a non-root user; the rootless quadlet uses the default user-namespace
# mapping (keep-id was tested 06.11.2026 and rejected on the server — crun
# Permission denied on the overlay merged dir; GNMON-000 M5), so the image
# user maps into the gn-dashboard subuid range on the host.
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
WORKDIR /src

# Restore first so the layer cache survives source edits.
COPY Ghostnet.Dashboard.csproj .
RUN dotnet restore Ghostnet.Dashboard.csproj

COPY . .
# No --no-restore: with the cached restore the publish could run with stale
# package data and drop wwwroot/_framework/blazor.web.js (404 in the
# container, Befund 09.11.2026); a full restore+publish keeps it.
RUN dotnet publish Ghostnet.Dashboard.csproj -c Release -o /app

FROM mcr.microsoft.com/dotnet/aspnet:10.0
WORKDIR /app
COPY --from=build /app .

# Non-root runtime user; keeps UID equal to the host workload account
# (gn-dashboard, 984) so host-side processes are attributable.
ENV ASPNETCORE_URLS=http://127.0.0.1:8080 \
    DOTNET_GENERATE_ASPNET_KEY=true
USER 984:984
EXPOSE 8080
ENTRYPOINT ["dotnet", "Ghostnet.Dashboard.dll"]
