# 使用 .NET 8 SDK 作为构建环境 FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build WORKDIR /src # 复制项目文件并还原依赖项 COPY . . RUN dotnet restore "Netnr.Admin.Web/Netnr.Admin.Web.csproj" # 设置工作目录为主项目目录 WORKDIR /src/Netnr.Admin.Web # 发布应用程序 RUN dotnet publish -c Release -o /app/out # 运行时环境 FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS runtime WORKDIR /app # 复制发布的输出文件到运行时镜像 COPY --from=build /app/out ./ # 暴露端口 EXPOSE 7713 # 启动应用程序 ENTRYPOINT ["dotnet", "Netnr.Admin.Web.dll"] CMD ["--urls", "http://+:7713"] # 附目录结构 # root/ # -- Dockerfile # -- Netnr.Admin.Domain/ # -- Netnr.Admin.Application/ # -- Netnr.Admin.Web/ # -- Netnr.Shared/