#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM 10.99.253.167:8090/dotnet/aspnet:9.0 AS base
# CURL install (bullseye - for net core 7!!!)
#RUN rm -f /etc/apt/sources.list.d/* && \
#    echo "deb [trusted=yes] http://10.99.253.167:8081/repository/apt-proxy bullseye main" > /etc/apt/sources.list && \
#    echo "deb [trusted=yes] http://10.99.253.167:8081/repository/apt-proxy bullseye-updates main" >> /etc/apt/sources.list && \
#    apt-get update && \
#    apt-get install -y curl && \
#    rm -rf /var/lib/apt/lists/*
WORKDIR /app

#ENV ASPNETCORE_HTTP_PORTS=80
ENV ASPNETCORE_URLS=http://+:80
EXPOSE 80

FROM 10.99.253.167:8090/dotnet/sdk:9.0 AS build
USER root
WORKDIR /src
COPY ["NuGet.config", "."]
COPY ["PARR.API/PARR.API.csproj", "PARR.API/"]
COPY ["PARR.Core/PARR.Core.csproj", "PARR.Core/"]
COPY ["PARR.Domain/PARR.Domain.csproj", "PARR.Domain/"]
COPY ["PARR.DAL/PARR.DAL.csproj", "PARR.DAL/"]
COPY ["PARR.Infrastructure/PARR.Infrastructure.csproj", "PARR.Infrastructure/"]
COPY ["CHANGELOG.md", "PARR.API/"]
RUN dotnet restore "PARR.API/PARR.API.csproj"
COPY . .
WORKDIR "/src/PARR.API"
RUN dotnet build "PARR.API.csproj" -c Release -o /app/build

FROM build AS publish
ARG app_version=0.0.0-default
RUN dotnet publish "PARR.API.csproj" -c Release -o /app/publish /p:UseAppHost=false /p:Version=$app_version
COPY --from=build /src/PARR.API/CHANGELOG.md /app/publish/wwwroot/

FROM base AS final

#author
ARG commit_author=unknown
LABEL org.opencontainers.image.authors=$commit_author

WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "PARR.API.dll"]


### EXAMPLE ###
# docker build -t parr-api:v1.0.0 --build-arg app_version=1.0.0 -f PARR.API/Dockerfile .
