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 . .

RUN dotnet restore "LiteCharmsSecurity.AdminUI.sln"

WORKDIR "/app_source/src/LiteCharmsSecurity.Admin.Api"
RUN dotnet build "LiteCharmsSecurity.Admin.Api.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "LiteCharmsSecurity.Admin.Api.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.Admin.Api.dll"]