You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

OpenShift构建流水线中dotnet restore执行耗时过长问题求助

OpenShift构建流水线中dotnet restore延迟严重问题

问题描述

在OpenShift构建流水线执行过程中,Dockerfile内的dotnet restore命令执行延迟严重,导致整体构建流程显著变慢。

我的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 8080
EXPOSE 8081

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
ARG HTTP_PROXY="<my-url-local-proxy>"
ENV DOTNET_NUGET_SIGNATURE_VERIFICATION=false
WORKDIR /src
COPY ["My.API/My.API.csproj", "My.API/"]
COPY ["My.Application/My.Application.csproj", "My.Application/"]
COPY ["My.Infrastructure/My.Infrastructure.csproj", "My.Infrastructure/"]
COPY "My.API/nuget.config" .

RUN dotnet restore -v diag "./My.API/./My.API.csproj"
COPY . .
WORKDIR "/src/My.API"
RUN dotnet build "./My.API.csproj" -c $BUILD_CONFIGURATION -o /app/build

FROM build AS publish
RUN dotnet publish "./My.API.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .

ENTRYPOINT ["dotnet", "My.API.dll"]

我的nuget.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <clear />
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
  </packageSources>
</configuration>

版本信息

  • 使用OpenShift 4版本

当前结果

  • 本地环境:Dockerfile可正常执行
  • OpenShift环境:dotnet restore操作持续耗时1小时,且在MSBuild阶段似乎超时

补充信息

  • 已添加ENV DOTNET_NUGET_SIGNATURE_VERIFICATION=false禁用NuGet签名包验证,问题未解决
  • Dockerfile中已配置代理变量并使用nuget.config文件
  • 尝试构建简单Node应用镜像时,npm install步骤同样卡住,推测与dotnet restore问题原因相同
  • 已检查资源配额,CPU、内存等均未达到限制
  • 尝试将aspnet:8.0更换为aspnet:7.0,问题仍未解决

恳请提供相关见解或指导,感谢支持。


内容的提问来源于stack exchange,提问作者linhvuquach

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.29 08:50:33