FROM mcr.microsoft.com/dotnet/core/aspnet:2.1-stretch-slim AS base
WORKDIR /app
RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' >/etc/timezone

FROM mcr.microsoft.com/dotnet/core/sdk:2.1-stretch AS build
WORKDIR /src
COPY ShortagePush/ShortagePush.csproj ShortagePush/
COPY AutoTurnOver.Services/AutoTurnOver.Services.csproj AutoTurnOver.Services/
COPY AutoTurnOver.DB/AutoTurnOver.DB.csproj AutoTurnOver.DB/
COPY AutoTurnOver.Utility/AutoTurnOver.Utility.csproj AutoTurnOver.Utility/
COPY AutoTurnOver.Models/AutoTurnOver.Models.csproj AutoTurnOver.Models/
RUN dotnet restore ShortagePush/ShortagePush.csproj
COPY . .
WORKDIR /src/ShortagePush
RUN dotnet build ShortagePush.csproj -c Release -o /app

FROM build AS publish
RUN dotnet publish ShortagePush.csproj -c Release -o /app

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