cirocosta / gitserver-http

git-http-backend with repository initialization
MIT License
21 stars 22 forks source link

TROUBLESHOOTING MUST READ #15

Open Nik-Novak opened 4 years ago

Nik-Novak commented 4 years ago

@cirocosta If you're reading this please revert to your :formatting tag on Dockerhub. It may just save lives.

As for anyone else:

I will save you a LOT of time through reading this. I struggled for 2 full days to get a http git server running on docker (from building it yourself, to looking for others who have). I now know git and nginx in and out, but at the cost of a huge dent in my desk from where my forehead made contact multiple times.

Both when I built it myself from scratch as well as when I tried using this Dockerimage, I kept running into 502/504 errors which meant nginx was timing out when trying to pass to the FCGI socket.

I tried literally everything possible to try and fix/debug, and finally narrowed it down to alpine linux having been updates, and with that the fcgiwrap package was updated and broke for the use case of setting up a git http server.

But I finally found a solution: Revert alpine to a version before 2018. You can see the alpine version history here: https://github.com/docker-library/official-images/commits/master/library/alpine And also check what versions of packages APK offers per version of alpine: https://pkgs.alpinelinux.org/packages?name=spawn-fcgi&branch=v3.5

Or, if like me you're completely beat by hours upon hours wasted:

  1. Create your repositories folder beforehand using your regular host user (avoid root as it causes issues), and mount it to the container.
  2. USE "circosta/gitserver-http:formatting" as the image to run from. The :formatting tag is the last version that was working, and

docker run -it --name omgItFinallyWorks -v $PWD/repositories:/var/lib/git -p 9000:80 circosta/gitserver-http:formatting

And from there you can add authentication, SSL, etc by modifying the nginx config.

Toss a coin to your code-fixer

catks commented 3 years ago

Hi, I managed to fix it, although I dropped Nginx and FastCGI approach and starting to use git-http-server and git-http-backend, I also add a git pull test and fixed node and alpine version, so the image is less likely to break in the future, if you need to use this image for testing I think this will be suitable enough, at least it is for me.

I also pushed an image for the forked version in my docker hub, so anyone can use with catks/gitserver-http:0.1.0

More details can be seen in the fork, although it has the same interface for initializing existing project folders.