I currently have a Dockerfile that I'm trying to get working to build a .NET project which uses Paket. A minimal example of it is as follows:
FROM mcr.microsoft/dotnet/sdk:8.0 AS result
# Install Paket etc
# Copy in source code
COPY ./global.json ./paket.dependencies ./paket.lock ./MyProject.sln .
COPY ./.paket/ .paket/
RUN --mount=type=bind,source="c:/Users/User.Name/.nuget/packages",target=/root/.nuget/packages \
/root/.dotnet/tools/paket restore
With the last step in the Dockerfile, I'm trying to mount the C:\Users\User.Name\.nuget\packages
folder so that can be used as a cache, and the packages don't have to be pulled down every time. However, when doing this, Docker complains that it could not compute the checksum of this directory, and that it does not exist. Using a relative path to that folder doesn't work either. Any suggestions would be greatly appreciated.
I currently have a Dockerfile that I'm trying to get working to build a .NET project which uses Paket. A minimal example of it is as follows:
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS result
# Install Paket etc
# Copy in source code
COPY ./global.json ./paket.dependencies ./paket.lock ./MyProject.sln .
COPY ./.paket/ .paket/
RUN --mount=type=bind,source="c:/Users/User.Name/.nuget/packages",target=/root/.nuget/packages \
/root/.dotnet/tools/paket restore
With the last step in the Dockerfile, I'm trying to mount the C:\Users\User.Name\.nuget\packages
folder so that can be used as a cache, and the packages don't have to be pulled down every time. However, when doing this, Docker complains that it could not compute the checksum of this directory, and that it does not exist. Using a relative path to that folder doesn't work either. Any suggestions would be greatly appreciated.
1 Answer
Reset to default 0What I ended up doing was reading the Paket documentation. I realised that it uses the paket.dependencies and paket.lock file to figure out what dependencies it needs to install.
So in the Dockerfile, I first copied in these two files and then did the paket restore before copying in the rest of the sourcecode and building it. This allows these two layers to be cached, and they don't have to be re-run unless the paket.dependencies or paket.lock changes.
RUN --mount=type=cache,target=...
without naming a specific host directory? – David Maze Commented Jan 20 at 2:32paket restore
curiously. I'll specify my steps for how I solved this. – flying_loaf_3 Commented 2 days ago