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

#这种模式是直接在构建镜像的内部编译发布dotnet项目。
#注意下容器内输出端口是9291
#如果你想先手动dotnet build成可执行的二进制文件，然后再构建镜像，请看.Api层下的dockerfile。


#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/aspnet:8.0 AS base
WORKDIR /app
EXPOSE 80

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
COPY ["Tiobon.Core.Api/Tiobon.Core.Api.csproj", "Tiobon.Core.Api/"]
COPY ["Tiobon.Core.Extensions/Tiobon.Core.Extensions.csproj", "Tiobon.Core.Extensions/"]
COPY ["Tiobon.Core.EventBus/Tiobon.Core.EventBus.csproj", "Tiobon.Core.EventBus/"]
COPY ["Tiobon.Core.Common/Tiobon.Core.Common.csproj", "Tiobon.Core.Common/"]
COPY ["Tiobon.Core.Model/Tiobon.Core.Model.csproj", "Tiobon.Core.Model/"]
COPY ["Tiobon.Core.Serilog.Es/Tiobon.Core.Serilog.Es.csproj", "Tiobon.Core.Serilog.Es/"]
COPY ["Ocelot.Provider.Nacos/Ocelot.Provider.Nacos.csproj", "Ocelot.Provider.Nacos/"]
COPY ["Tiobon.Core.Services/Tiobon.Core.Services.csproj", "Tiobon.Core.Services/"]
COPY ["Tiobon.Core.IServices/Tiobon.Core.IServices.csproj", "Tiobon.Core.IServices/"]
COPY ["Tiobon.Core.Repository/Tiobon.Core.Repository.csproj", "Tiobon.Core.Repository/"]
COPY ["Tiobon.Core.Tasks/Tiobon.Core.Tasks.csproj", "Tiobon.Core.Tasks/"]
COPY ["build", "build/"]
RUN dotnet restore "Tiobon.Core.Api/Tiobon.Core.Api.csproj"
COPY . .
WORKDIR "/src/Tiobon.Core.Api"
RUN dotnet build "Tiobon.Core.Api.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "Tiobon.Core.Api.csproj" -c Release -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
EXPOSE 9291 
ENTRYPOINT ["dotnet", "Tiobon.Core.Api.dll"]
