FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 8080
EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["../../RBLNews.Web/RBLNews.Web.csproj", "RBLNews.Web/"]
COPY ["../../RBLNews.Shared/RBLNews.Shared.csproj", "RBLNews.Shared/"]
RUN dotnet nuget add source --name itob https://git.wohlleben.dev/api/packages/itob/nuget/index.json
RUN dotnet restore "RBLNews.Web/RBLNews.Web.csproj"
COPY . .
WORKDIR "/src/RBLNews.Web"
RUN dotnet build "RBLNews.Web.csproj" -c $BUILD_CONFIGURATION -o /app/build

FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "RBLNews.Web.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .

# set time zone
RUN apt-get update && apt-get install -y tzdata
ENV TZ=Europe/Berlin
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

ENTRYPOINT ["dotnet", "RBLNews.Web.dll"]