FROM microsoft/dotnet:2.1-runtime-alpine AS base
WORKDIR /app
RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' >/etc/timezone

FROM microsoft/dotnet:2.1-sdk-alpine AS build
WORKDIR /src
COPY ResetOutofstock/ResetOutofstock.csproj ResetOutofstock/
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 ResetOutofstock/ResetOutofstock.csproj
COPY . .
WORKDIR /src/ResetOutofstock
RUN dotnet build ResetOutofstock.csproj -c Release -o /app

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

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