#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

#定义时区参数
ENV TZ=Asia/Shanghai

#设置时区
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo '$TZ' > /etc/timezone

FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
WORKDIR /src
COPY ["aspnet-core/src/YGNT.Exam.Web.Host/YGNT.Exam.Web.Host.csproj", "src/YGNT.Exam.Web.Host/"]
COPY ["aspnet-core/src/YGNT.File/YGNT.File.Application/YGNT.File.Application.csproj", "src/YGNT.File/YGNT.File.Application/"]
COPY ["aspnet-core/src/YGNT.File/YGNT.File.Core/YGNT.File.Core.csproj", "src/YGNT.File/YGNT.File.Core/"]
COPY ["aspnet-core/src/YGNT.Exam.Web.Core/YGNT.Exam.Web.Core.csproj", "src/YGNT.Exam.Web.Core/"]
COPY ["aspnet-core/src/YGNT.Exam.EntityFrameworkCore/YGNT.Exam.EntityFrameworkCore.csproj", "src/YGNT.Exam.EntityFrameworkCore/"]
COPY ["aspnet-core/src/YGNT.Exam.Core/YGNT.Exam.Core.csproj", "src/YGNT.Exam.Core/"]
COPY ["aspnet-core/src/YGNT.QuestionLibrary/YGNT.QuestionLibrary.Core/YGNT.QuestionLibrary.Core.csproj", "src/YGNT.QuestionLibrary/YGNT.QuestionLibrary.Core/"]
COPY ["aspnet-core/src/YGNT.QuestionLibrary/YGNT.QuestionLibrary.Application/YGNT.QuestionLibrary.Application.csproj", "src/YGNT.QuestionLibrary/YGNT.QuestionLibrary.Application/"]
COPY ["aspnet-core/src/YGNT.Exam.Application/YGNT.Exam.Application.csproj", "src/YGNT.Exam.Application/"]
COPY ["aspnet-core/src/YGNT.QuestionLibrary/YGNT.QuestionLibrary.EntityFrameworkCore/YGNT.QuestionLibrary.EntityFrameworkCore.csproj", "src/YGNT.QuestionLibrary/YGNT.QuestionLibrary.EntityFrameworkCore/"]
RUN dotnet restore "src/YGNT.Exam.Web.Host/YGNT.Exam.Web.Host.csproj"
COPY . .
WORKDIR "/src/aspnet-core/src/YGNT.Exam.Web.Host"
RUN dotnet build "YGNT.Exam.Web.Host.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "YGNT.Exam.Web.Host.csproj" -c Release -o /app/publish

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