0

I'm working on a .net core 3.1 project for a company. I have a pretty simple dockerfile configured that leverages RUN dontnet restore to retrieve all the necessary nuget packages for my project. This works fine for me. It will build and run the container no problem.

The problem comes when the company pulls my solution to their network and they try to run the same dockerfile. Their firewall rules block SSL connections to external sites (with explicit exceptions that nuget is not part of). So when they try to build the container they get failure when the restore tries to access "https://api.nuget.org/v3/index.json". Which makes sense to me for the reasons above.

If I update my dotnet build to include nuget packages as part of the published output, can I have the dockerfile update to reference that published output for nuget packages instead of doing a dotnet restore from nuget itself? Essentially is there a good way to handle the docker build process so it can be done offline (i.e. without relying on external sources)?

1
  • 1
    Why do you ship a Docker image that requires dotnet restore? Why not use self-contained deployment?
    – Lex Li
    Commented Apr 25, 2020 at 3:17

2 Answers 2

1

You could create a local cache using NuSave, then add it to your Docker container; which can be used to restore the solution offline.

0

As @Lex Li mentioned above, the better way to do things was a self contained publish with dotnet and then copying those files over into the container so that there was no need to do a dotnet restore.

I typically like to do dotnet restore to keep the size small but in this case this was the right way to do it.

Not the answer you're looking for? Browse other questions tagged or ask your own question.