Being in a new area in a lockdown zone, I only have access to badly overpriced sim card data plans right now and I am looking for a way to minimize bandwidth.
I have an app that has a regular dockerfile for its build, but it will go online to restore packages every time.
I am on MacOS and the build process doesn't need to be portable.
Since I have a local nuget package cache (~/.nuget/packages), I would like to leverage this and re-use these files.
First, I would like to point out that doing a publish from my IDE and using that result is not an option with this project, I really need to build it from source.
There are also numerous discussions on either directly or semi-related situation and a few blog posts and none seem to come up with an ideal solution. I did quite an extensive search. If you think this is a duplicate of an existing post with a valid solution, please have a close look.
Things I have looked at:
- Can I mount the .nuget cache into a volume and use it during the docker build process. The answer seems to be no, as there is no -v / --volume option with docker build.
- Can I install a local nuget server? the only valid MacOS solution I found is BaGet and, while trying to make it work, I noticed an open ticket where it says that package dependencies are not pulled when using it as a cache, so it's not a valid solution.
- Can I restore all the packages once in one layer of the docker build. Possibly, but it is tricky because there are a lot of sub-projects imported and this means the packages will be regularly re-imported on changes.
What I am currently looking at is:
- make the .nuget folder part of the build folder through a symlink
- find all the fsproj files to include and then copy them in one layer of the docker build
- do a dotnet restore using the symlink as a package source
- do a build, as the next layer
one issue is that I can't hardcode the fsproj dependencies and it is not possible to find all the project files from inside the dockerfile. One blog post suggests a pre-process where the files are found, put in an archive, and expand it in the dockerfile.
before I start to go on some convoluted path, has anyone tried to solve this problem before? or came up with a good clean solution?
edit:
docker will not access symlinks pointing outside of the build directory