# 请参阅 https://aka.ms/customizecontainer 以了解如何自定义调试容器,以及 Visual Studio 如何使用此 Dockerfile 生成映像以更快地进行调试。 # 此阶段用于在快速模式(默认为调试配置)下从 VS 运行时 FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base USER $APP_UID WORKDIR /app EXPOSE 80 # 此阶段用于生成服务项目 FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build ARG BUILD_CONFIGURATION=Release WORKDIR /src COPY ["CoreCms.Net.Web.Admin/CoreCms.Net.Web.Admin.csproj", "CoreCms.Net.Web.Admin/"] COPY ["CoreCms.Net.Auth/CoreCms.Net.Auth.csproj", "CoreCms.Net.Auth/"] COPY ["CoreCms.Net.Configuration/CoreCms.Net.Configuration.csproj", "CoreCms.Net.Configuration/"] COPY ["CoreCms.Net.Model/CoreCms.Net.Model.csproj", "CoreCms.Net.Model/"] COPY ["CoreCms.Net.IRepository/CoreCms.Net.IRepository.csproj", "CoreCms.Net.IRepository/"] COPY ["CoreCms.Net.IServices/CoreCms.Net.IServices.csproj", "CoreCms.Net.IServices/"] COPY ["CoreCms.Net.Utility/CoreCms.Net.Utility.csproj", "CoreCms.Net.Utility/"] COPY ["CoreCms.Net.CodeGenerator/CoreCms.Net.CodeGenerator.csproj", "CoreCms.Net.CodeGenerator/"] COPY ["CoreCms.Net.Core/CoreCms.Net.Core.csproj", "CoreCms.Net.Core/"] COPY ["CoreCms.Net.Caching/CoreCms.Net.Caching.csproj", "CoreCms.Net.Caching/"] COPY ["CoreCms.Net.Loging/CoreCms.Net.Loging.csproj", "CoreCms.Net.Loging/"] COPY ["CoreCms.Net.RedisMQ/CoreCms.Net.RedisMQ.csproj", "CoreCms.Net.RedisMQ/"] COPY ["CoreCms.Net.WeChat.Service/CoreCms.Net.WeChat.Service.csproj", "CoreCms.Net.WeChat.Service/"] COPY ["CoreCms.Net.Swagger/CoreCms.Net.Swagger.csproj", "CoreCms.Net.Swagger/"] COPY ["CoreCms.Net.Filter/CoreCms.Net.Filter.csproj", "CoreCms.Net.Filter/"] COPY ["CoreCms.Net.Mapping/CoreCms.Net.Mapping.csproj", "CoreCms.Net.Mapping/"] COPY ["CoreCms.Net.Middlewares/CoreCms.Net.Middlewares.csproj", "CoreCms.Net.Middlewares/"] COPY ["CoreCms.Net.Repository/CoreCms.Net.Repository.csproj", "CoreCms.Net.Repository/"] COPY ["CoreCms.Net.Services/CoreCms.Net.Services.csproj", "CoreCms.Net.Services/"] COPY ["CoreCms.Net.Task/CoreCms.Net.Task.csproj", "CoreCms.Net.Task/"] RUN dotnet restore "./CoreCms.Net.Web.Admin/CoreCms.Net.Web.Admin.csproj" COPY . . WORKDIR "/src/CoreCms.Net.Web.Admin" RUN dotnet build "./CoreCms.Net.Web.Admin.csproj" -c $BUILD_CONFIGURATION -o /app/build # 此阶段用于发布要复制到最终阶段的服务项目 FROM build AS publish ARG BUILD_CONFIGURATION=Release RUN dotnet publish "./CoreCms.Net.Web.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", "CoreCms.Net.Web.Admin.dll"]