FROM mcr.microsoft.com/dotnet/sdk:8.0 as build

#install debugger for NET Core
RUN apt-get update
RUN apt-get install -y unzip
RUN curl -sSL https://aka.ms/getvsdbgsh | /bin/sh /dev/stdin -v latest -l ~/vsdbg

RUN mkdir /src/
WORKDIR /src/

COPY ./src/helloworld.csproj /src/helloworld.csproj
RUN dotnet restore

COPY ./src/ /src/
RUN mkdir /out/

RUN dotnet build helloworld.csproj --configuration Debug --no-restore
RUN dotnet publish helloworld.csproj --output /out --configuration Debug --no-restore

ENTRYPOINT ["dotnet", "run"]

FROM mcr.microsoft.com/dotnet/aspnet:8.0 as runtime

WORKDIR /app
COPY --from=build /out/ /app

ENTRYPOINT ["dotnet", "helloworld.dll"]
