FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
WORKDIR /src

COPY src/New.Domain/New.Domain.csproj src/New.Domain/
COPY src/New.Application/New.Application.csproj src/New.Application/
COPY src/New.Infrastructure.Persistence/New.Infrastructure.Persistence.csproj src/New.Infrastructure.Persistence/
COPY src/New.Infrastructure.Legacy/New.Infrastructure.Legacy.csproj src/New.Infrastructure.Legacy/
COPY src/New.Infrastructure.CaseFramework/New.Infrastructure.CaseFramework.csproj src/New.Infrastructure.CaseFramework/
COPY src/New.Api/New.Api.csproj src/New.Api/

COPY src/ src/
# restore+publish combined in one RUN/layer: podman/buildah has a known issue
# where the NuGet global-packages cache uses hardlinks that break when a
# restore layer and a later --no-restore publish layer are committed
# separately, surfacing as a false "package not found" error.
RUN dotnet restore src/New.Api/New.Api.csproj && \
    dotnet publish src/New.Api/New.Api.csproj -c Release -o /app --no-restore

FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS runtime
WORKDIR /app
COPY --from=build /app .
EXPOSE 8080
ENTRYPOINT ["dotnet", "New.Api.dll"]
