lib2gitsharp mmap permission denied in docker

246 Views Asked by At

I'm struggling to get lib2gitsharp (0.27.0-preview-0007) to work in a docker container. Heres a cut-down version of my dockerfile:

FROM mcr.microsoft.com/dotnet/aspnet:5.0-buster-slim AS base
# Normal .net setup

FROM base AS final
ENV LD_LIBRARY_PATH=/app/runtimes/debian.9-x64/native/
ENV LD_DEBUG=all
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "mydll.dll"]

And the c# code that executes causing the issue:

var token = await gitRepo.GetToken("my", "details");
Console.WriteLine($"Got git token {token}");

var path = Path.Combine("/mountedfeatures", $"mysubfolder");
Directory.CreateDirectory(path);

Console.WriteLine("Cloning git repo...");
gitRepo.Clone(gitServer, path, token);

Then, on the gitRepo line, after successfully creating the new folder, I get:

 LibGit2Sharp.LibGit2SharpException: failed to mmap. Could not write data: Permission denied
|    at LibGit2Sharp.Core.Ensure.HandleError(Int32 result)
|    at LibGit2Sharp.Core.Ensure.ZeroResult(Int32 result)
|    at LibGit2Sharp.Core.Proxy.git_clone(String url, String workdir, GitCloneOptions& opts)
|    at LibGit2Sharp.Repository.Clone(String sourceUrl, String workdirPath, CloneOptions options)

From what I can tell, this isn't a file permission error, as we successfully create the directory a couple of lines up from the clone. Looking at other mmap issues on SO the advice is to change the call itself, which I obviously don't have access to. I can't see any way of passing additional info in the call itself, so I'm pretty stuck.

On the other hand I can't see anyone else having this issue, so I'm assuming I must be doing something wrong, does anyone have any ideas?

Alternatively, if anyone knows of an alternate git library I could use in .net I don't mind switching out the implementation.

0

There are 0 best solutions below