Docker build failed with local Nuget packages

1 Answer 9209 Views
General Discussions Installer and VS Extensions
Lars1603
Top achievements
Rank 1
Iron
Lars1603 asked on 04 Aug 2021, 10:12 AM
Hi everyone,

I have a little problem with containerizing my application and I hope that you can help me.
I am currently programming an ASP.NET Core web application using the Nuget package Telerik UI for ASP.NET Core. In order to use this package I have given a local path on my hard drive where the nupkg file is located. (see picture 1)

For the containerization I created the Dockerfile and the Docker-Compose. Everything worked fine during development, but as soon as I try to containerize the app with the command "docker-compose build", I get the following error. -> Unable to find package Telerik.UI.for.AspNet.Core with version> = 2021.2.511 (see picture 2)

I've read that I need a nuget.config file. I created this with the command "dotnet new nugetconfig". Then I added the package source "local" and "nuget.org". "local" refers to the folder "Package" that I created in the project folder and into which I copied the nupkg file. (see picture 3)

If I run the "docker-compose build" command again, I get another error -> The local source [...] doesn't exist (see image 4)

So my question is what do I have to do in order for the Nuget package to be found and the Docker build to work?
(My Dockerfile and Docker-Compose can also be found in the attachments)

Thanks in advance
Lars

1 Answer, 1 is accepted

Sort by
1
Aleksandar
Telerik team
answered on 09 Aug 2021, 07:29 AM

Hi Lars,

Looking at the first picture I see that the path to local packages is C:\nugetPackages but on pic 3 the pat is .\Packages so I am not sure if they are pointing to the same location. 

I have also searched the web for suggestions on how to restore NuGet packages from local feed in .Net Core application in Docker. Here are some resources that you may find useful:

https://stackoverflow.com/questions/48821991/dockerfile-cant-see-local-file-or-private-nuget-server 

If you decide to use the private Telerik NuGet Feed, make sure to follow this tutorial https://docs.telerik.com/aspnet-core/installation/nuget-install#setup-with-nugetconfig on setting up the private NuGet feed. you can also check the section on deployment and build servers.

Regards,
Aleksandar
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Lars1603
Top achievements
Rank 1
Iron
commented on 01 Sep 2021, 07:41 AM

Hi Aleksandar

Thank you for your help.

The one with the ".\Packages" is correct, because I copied the NuGet package once into the project folder and use it from there during the Docker build process and not from "C:\NuGetPackages"

I have now found a solution for my problem. This was actually easier than expected. In the Dockerfile I only had to use the command "COPY . ." insert above "COPY nuget.config". The Nuget package is first copied into the Docker container and could then be found by the nuget.config. I added the Dockerfile as a picture in the attachment.

Best regards
Lars

Aleksandar
Telerik team
commented on 03 Sep 2021, 11:04 AM

I am glad to hear you were able to resolve the issue and thank you also for sharing it with the community.
Tags
General Discussions Installer and VS Extensions
Asked by
Lars1603
Top achievements
Rank 1
Iron
Answers by
Aleksandar
Telerik team
Share this question
or