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

COPY src/Legacy.Api/ src/Legacy.Api/
# 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/Legacy.Api/Legacy.Api.csproj && \
    dotnet publish src/Legacy.Api/Legacy.Api.csproj -c Release -o /app/publish --no-restore

FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS runtime
WORKDIR /app
COPY --from=build /app/publish .

EXPOSE 8080
ENTRYPOINT ["dotnet", "Legacy.Api.dll"]
