s2i-dotnetcore icon indicating copy to clipboard operation
s2i-dotnetcore copied to clipboard

Dotnet core S2i build error ssl connects to wrong nuget

Open codeground123 opened this issue 2 years ago • 10 comments

I am trying to build my solution and create docker image using OpenShift S2i pattern.

Using the below command to build the repository

oc new-app dotnet:3.1~http://azureserver.abc.com:8080/tfs/_git/Emp-WebServices --name employeewebservice

we are unable to connect to the Nuget Private repository internal to our network, in the logs it tries to connect to nuget.org to pull our private packages and not connecting to our Company's hosted Nuget config

/opt/app-root/src/Emp.WebServices/Emp.WebService...ler. No packages exist with this id in source(s): nuget.org
/opt/app-root/src/Emp.WebServices/Emp.WebService...ter. No packages exist with this id in source(s): nuget.org
/opt/app-root/src/Emp.WebServices/Emp.WebService...ter. No packages exist with this id in source(s): nuget.org
  Restore failed in 2.14 min for /opt/app-root/src/Emp.WebServices/Emp.WebServices.csproj.
error: build error: error building at STEP "RUN /tmp/scripts/assemble": error while running runtime: exit status 1

Below is our environment file in s2i folder and its contents


ASPNETCORE_ENVIRONMENT=Production
DOTNET_STARTUP_PROJECT=Emp.WebServices/Emp.WebServices.csproj
DOTNET_RESTORE_CONFIGFILE=Nuget/NuGet.Config
DOTNET_CONFIGURATION=Release
HTTP_PROXY=http://proxy-web.avc.com:80
HTTPS_PROXY=http://proxy-web.avc.com:80	
NO_PROXY=localhost,.avc.com
DOTNET_SSL_DIRS=certificates

Placed ca-bundle.crt in the certificates folder which is in the root of our project

Also below is our nuget config in the root folder nuget/nuget.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <solution>
    <add key="disableSourceControlIntegration" value="true" />
  </solution>
  <packageSources>
    <add key="AvcNuGet" value="http://abcnugeto1.avc.com/nuget" />
    <add key="nuget.org" value="https://api.nuget.org/v3/" />
	  </packageSources>
  <packageRestore>
    <add key="enabled" value="True" />
  </packageRestore>
</configuration>

Am I missing any thing, we are stuck with this since long and not able to find good resources on how to build this.

codeground123 avatar Aug 10 '22 15:08 codeground123

@phaniwithu Out of curiosity, what happens if you explicitly specify the config file using the DOTNET_RESTORE_CONFIGFILE environment variable?

aslicerh avatar Aug 10 '22 22:08 aslicerh

we have specified explicitly only, below is the environment variables where we are specifying the DOTNET_RESTORE_CONFIGFILE

ASPNETCORE_ENVIRONMENT=Production
DOTNET_STARTUP_PROJECT=Emp.WebServices/Emp.WebServices.csproj
DOTNET_RESTORE_CONFIGFILE=Nuget/NuGet.Config
DOTNET_CONFIGURATION=Release
HTTP_PROXY=http://proxy-web.avc.com:80
HTTPS_PROXY=http://proxy-web.avc.com:80	
NO_PROXY=localhost,.avc.com
DOTNET_SSL_DIRS=certificates

Same error as mentioned in the question

is there any other way to do this ?

codeground123 avatar Aug 12 '22 10:08 codeground123

@phaniwithu Hey, sorry for missing that from your original post. Let me see if I can reproduce the issue and see what is going on.

aslicerh avatar Aug 16 '22 12:08 aslicerh

@aslicerh I was able to resolve this, place the nuget.config in the root folder where the .csproj file is there. Thanks for your comments

codeground123 avatar Aug 23 '22 04:08 codeground123

@aslicerh Also I noticed that even the subsequent builds take hours to complete, is there anyway to speed them up ?

codeground123 avatar Aug 23 '22 13:08 codeground123

@paoloantinori Do you see the same slowdown if you are using your proxy outside of a container, or only with the container? Looking at your logs, can you see what step is taking a long time? And in general, are you limiting the CPU for the containers, and if so, does your build time decrease if you give the containers more CPU quota?

aslicerh avatar Aug 23 '22 14:08 aslicerh

hello! I suspect the previous message was supposed to tag someone else

paoloantinori avatar Aug 23 '22 14:08 paoloantinori

@paoloantinori You are correct, I am so sorry about that. @phaniwithu Please see my previous comment.

aslicerh avatar Aug 23 '22 16:08 aslicerh

@paoloantinori Increasing the CPU fixed the issue of build taking too much time

codeground123 avatar Aug 25 '22 08:08 codeground123

@paoloantinori Increasing the CPU fixed the issue of build taking too much time

🙃

paoloantinori avatar Aug 25 '22 08:08 paoloantinori

It seems the issue is fixed. Closing.

tmds avatar Sep 06 '22 14:09 tmds