FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
ARG TARGETARCH
WORKDIR /app_source

# Copy everything from repository root into /app_source
COPY . .

# Restore the solution from the root context
RUN dotnet restore "LiteCharmsSecurity.sln"

# Paths match your repository exactly now: src/ is just under the root
WORKDIR "/app_source/src/LiteCharmsSecurity.STS.Identity"
RUN dotnet build "LiteCharmsSecurity.STS.Identity.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "LiteCharmsSecurity.STS.Identity.csproj" -c Release --no-restore -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENV ASPNETCORE_FORWARDEDHEADERS_ENABLED=true
ENTRYPOINT ["dotnet", "LiteCharmsSecurity.STS.Identity.dll"]