# Build context is the REPO ROOT (so Central Package Management's Directory.*.props
# at the root are available). Build with:
#   docker compose build   (compose sets the context)
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
WORKDIR /src

# Restore against the full solution sources the C2 transitively needs.
COPY Directory.Build.props Directory.Packages.props ./
COPY BlueLaminate/ BlueLaminate/
RUN dotnet restore BlueLaminate/BlueLaminate.C2/BlueLaminate.C2.csproj
RUN dotnet publish BlueLaminate/BlueLaminate.C2/BlueLaminate.C2.csproj \
    -c Release -o /app --no-restore

FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS runtime
# NOTE: deliberately do NOT install libgssapi-krb5-2. Without it Npgsql logs a
# harmless "cannot load libgssapi_krb5.so.2" line and falls back to password auth;
# WITH it, a failed/misconfigured connection attempt segfaults during GSS negotiation
# (observed: container exit 139 / crash-loop). Graceful failure beats the segfault.
WORKDIR /app
COPY --from=build /app ./
# Bind all interfaces inside the container (overrides appsettings' localhost binding).
ENV ASPNETCORE_URLS=http://+:5080
EXPOSE 5080
ENTRYPOINT ["dotnet", "BlueLaminate.C2.dll"]
