# 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 maps it onto the
# gn-dashboard host account (UID 984) via UserNS=keep-id.
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 . .
RUN dotnet publish Ghostnet.Dashboard.csproj -c Release -o /app --no-restore

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"]
