ARG DOTNET_SDK_IMAGE=mcr.microsoft.com/dotnet/sdk:10.0
ARG DOTNET_ASPNET_IMAGE=mcr.microsoft.com/dotnet/aspnet:10.0

FROM ${DOTNET_SDK_IMAGE} AS build
WORKDIR /src

COPY global.json Directory.Build.props Directory.Packages.props ./
# nuget.docker.config points to local Nexus mirror (mirror:8081 via extra_hosts in compose)
COPY nuget.docker.config ./nuget.config

COPY src/Meezi.Shared/Meezi.Shared.csproj src/Meezi.Shared/
COPY src/Meezi.Core/Meezi.Core.csproj src/Meezi.Core/
COPY src/Meezi.Infrastructure/Meezi.Infrastructure.csproj src/Meezi.Infrastructure/
COPY src/Meezi.API/Meezi.API.csproj src/Meezi.API/

ENV NUGET_CERT_REVOCATION_MODE=offline
RUN --mount=type=cache,target=/root/.nuget/packages \
    dotnet restore src/Meezi.API/Meezi.API.csproj --disable-parallel

COPY src/ src/
COPY data/menu-image-manifest.json data/
COPY data/demo-credentials.json data/
RUN dotnet publish src/Meezi.API/Meezi.API.csproj -c Release -o /app/publish /p:UseAppHost=false

FROM ${DOTNET_ASPNET_IMAGE} AS runtime
WORKDIR /app

ENV ASPNETCORE_URLS=http://+:8080
EXPOSE 8080

COPY --from=build /app/publish .

ENTRYPOINT ["dotnet", "Meezi.API.dll"]
