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

FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
EXPOSE 5000

FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
WORKDIR /app
RUN dotnet dev-certs https --clean
RUN dotnet dev-certs https -ep TEAMModelGrpc/habook.pfx  -p habook
#RUN dotnet dev-certs https --trust
COPY ["TEAMModelGrpc/habook.pfx", "/app"]

WORKDIR /src
COPY ["TEAMModelGrpc/habook.pfx", "TEAMModelGrpc/"]
COPY ["TEAMModelGrpc/nuget.config", "TEAMModelGrpc/"]
COPY ["TEAMModelGrpc/Protos", "TEAMModelGrpc/"]
COPY ["TEAMModelGrpc/TEAMModelGrpc.csproj", "TEAMModelGrpc/"]
COPY ["TEAMModelOS.SDK/TEAMModelOS.SDK.csproj", "TEAMModelOS.SDK/"]
COPY ["TEAMModelOS.Service/TEAMModelOS.Service.csproj", "TEAMModelOS.Service/"]
RUN dotnet restore "TEAMModelGrpc/TEAMModelGrpc.csproj" --configfile "TEAMModelGrpc/nuget.config"
COPY . .
WORKDIR "/src/TEAMModelGrpc"
RUN dotnet build "TEAMModelGrpc.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "TEAMModelGrpc.csproj" -c Release -o /app/publish
COPY ["TEAMModelGrpc/habook.pfx", "/app/publish"]

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "TEAMModelGrpc.dll"]
