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

# Copy everything
COPY . ./

RUN apt update && apt install libldap-2.5-0 -y

# Restore as distinct layers
RUN dotnet restore ./song_of_the_day/song_of_the_day.csproj
# Build and publish a release
RUN dotnet publish ./song_of_the_day/song_of_the_day.csproj -o out /p:EnvironmentName=Production

# Build runtime image
FROM mcr.microsoft.com/dotnet/aspnet:9.0
WORKDIR /App
RUN apt update && apt install libldap-2.5-0 -y
COPY --from=build /App/out .
ENTRYPOINT ["dotnet", "song_of_the_day.dll"]
