origin icon indicating copy to clipboard operation
origin copied to clipboard

Long Execution Time for dotnet restore in OpenShift Build Pipeline

Open linhvuquach opened this issue 1 year ago • 6 comments

During our build pipeline execution on OpenShift, we've encountered a significant delay specifically with the dotnet restore command in the Dockerfile. This delay is causing notable slowdowns in our overall build process.

My 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"]

My nugget.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>
Version

I'm using openshift version 4.

Current Result
  • Local result: I can work fine with my Dockerfile in my local.
  • OpenShift result: The dotnet restore operation consistently takes 1-hour duration and seems to time out during the MSBuild within our OpenShift build pipeline.
Additional Information
  • I saw a make sense information about NuGet signed-package verification https://github.com/NuGet/Home/issues/13062 and additional ENV DOTNET_NUGET_SIGNATURE_VERIFICATION=false in Dockerfile. But it didn't resolve yet.
    • You also need it for more information: https://learn.microsoft.com/en-us/dotnet/core/tools/nuget-signed-package-verification
  • In my Dockerfile I also add a Proxy variable and use nuget.config file. You can look at it above.
  • I tried to create another Node simple application image. But it also stuck on the npm install step. I think the same concept with the dotnet restore command.
  • I'm always looking at my resource quota. I don't see CPU, memory,... reach limit: image
  • I also tried to change aspnet:8.0 to aspnet:7.0. It still didn't success

Any insights or guidance will be expected. Thank you for your attention to this matter.

linhvuquach avatar Feb 23 '24 05:02 linhvuquach