# 请参阅 https://aka.ms/customizecontainer 以了解如何自定义调试容器,以及 Visual Studio 如何使用此 Dockerfile 生成映像以更快地进行调试。 # 此阶段用于在快速模式(默认为调试配置)下从 VS 运行时 FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base USER app WORKDIR /app EXPOSE 80 # 此阶段用于生成服务项目 FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build ARG BUILD_CONFIGURATION=Release WORKDIR /src COPY ["dll/CloudGaming.AppConfigModel.dll", "dll/"] COPY ["projects/project.targets", "projects/"] COPY ["CloudGaming.Api.Admin/CloudGaming.Api.Admin.csproj", "CloudGaming.Api.Admin/"] COPY ["CloudGaming.Code.DataBaseModel/CloudGaming.Code.DataBaseModel.csproj", "CloudGaming.Code.DataBaseModel/"] COPY ["CloudGaming.Code.Aliyun/CloudGaming.Code.Aliyun.csproj", "CloudGaming.Code.Aliyun/"] COPY ["CloudGaming.Core.Logs/CloudGaming.Core.Logs.csproj", "CloudGaming.Core.Logs/"] COPY ["CloudGaming.Core/CloudGaming.Core.csproj", "CloudGaming.Core/"] COPY ["CloudGaming.Core.Quartz/CloudGaming.Core.Quartz.csproj", "CloudGaming.Core.Quartz/"] COPY ["CloudGaming.Core.EntityFramework/CloudGaming.Core.EntityFramework.csproj", "CloudGaming.Core.EntityFramework/"] COPY ["CloudGaming.Core.Identity/CloudGaming.Core.Identity.csproj", "CloudGaming.Core.Identity/"] COPY ["CloudGaming.Core.Redis/CloudGaming.Core.Redis.csproj", "CloudGaming.Core.Redis/"] COPY ["CloudGaming.Core.AgileConfig/CloudGaming.Core.AgileConfig.csproj", "CloudGaming.Core.AgileConfig/"] COPY ["CloudGaming.Shared.Admin/CloudGaming.Shared.Admin.csproj", "CloudGaming.Shared.Admin/"] COPY ["CloudGaming.Repository.Admin/CloudGaming.Repository.Admin.csproj", "CloudGaming.Repository.Admin/"] COPY ["CloudGaming.Shared/CloudGaming.Shared.csproj", "CloudGaming.Shared/"] COPY ["CloudGaming.Core.Razor/CloudGaming.Core.Razor.csproj", "CloudGaming.Core.Razor/"] COPY ["CloudGaming.Core.Swagger/CloudGaming.Core.Swagger.csproj", "CloudGaming.Core.Swagger/"] COPY ["CloudGaming.Repository.Game/CloudGaming.Repository.Game.csproj", "CloudGaming.Repository.Game/"] RUN ls RUN dotnet restore "./CloudGaming.Api.Admin/CloudGaming.Api.Admin.csproj" COPY . . WORKDIR "/src/CloudGaming.Api.Admin" RUN dotnet build "./CloudGaming.Api.Admin.csproj" -c $BUILD_CONFIGURATION -o /app/build # 此阶段用于发布要复制到最终阶段的服务项目 FROM build AS publish ARG BUILD_CONFIGURATION=Release RUN dotnet publish "./CloudGaming.Api.Admin.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false # 此阶段在生产中使用,或在常规模式下从 VS 运行时使用(在不使用调试配置时为默认值) FROM base AS final WORKDIR /app COPY --from=publish /app/publish . ENTRYPOINT ["dotnet", "CloudGaming.Api.Admin.dll"]