Gitserver

A git repository running in a docker container

Download .zip Download .tar.gz
View the docs View on GitHub

Welcome

Sometimes you wonder why life couldn't be a bit easier...

To create a git server you need to have two ingredients:

  1. Git
  2. Ssh server

These two pieces of software are not always so straightforward to setup. However I believe the software developers have done everything they could do to make it simple as possible. But to set up a gitserver you need a good knowledge of both technologies.

The idea behind this project is to make the creation and maintenance of a git repository as simple as possible, without compromising security.

Docker

Docker is a nice way to put pieces of software in containers. One of the big advantages of docker is that you can use only what you need to run a particular piece of software. Docker images tends to grow and sizes of more than 500MB are not uncommon. To reduce the size you can choose from many different linux distributions. I picked alpine linux to do the job¸as docker image is it is emere 2MB in size. For reference ubuntu starts at 50MB.

Security

Security plays an important role in this project. You can find details of hardening the ssh server on this page: https://stribika.github.io/2015/01/04/secure-secure-shell.html

Let's get started

First you want a running gitserver.

docker run -d -p 2222:22 --restart always --name devteam ensignprojects/gitserver

Configure this server

Add the signed keys to the gitservers of each member of the developer team who needs access to the software projects on the server. If you want to know how to generate these keys, go to: https://help.github.com/articles/generating-ssh-keys/

docker exec -it devteam key add ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQD6hLTCJQ0J9e3KxrG3dqZqWY/Wth9gHT6KyOgylTsmaRHKQfa1Xsdsj54S/JOM/pVqK9XK00KHxWUovvvaLlXErjOgb2PWaJa/0HNtMo80M6nXAtWcP07fSTxdvSZd+ZJC+DszkSciAZmeMKhKAb2+JT/rlCS1a1DF6GpGSsG2Pzo+iuViIywRbdik1fmDmNPyAdauQW6JG5ulBiWBph8/ElpE8DLBwaINUrN4m/tShUUIyB3wI+e5ublGlIheRkkmj66vKvcvTt93GxmLlPR/kg+oY0T8ygZZu5GKQifAVvsy2jgqlKegPHtltr7dpixrPK6b2jA3fWl6VG6f/pa9xOpSJzeimvIA6KInDkVbkwueW662aVPW7OrxUwxFsh56bUrKdpE+e7o6VByA3nAz9KBIEY9JXV/3oUoxJ7zv+vOKN/3vtep2YhianQr4Yzx9/QDlUFcYwANfljRZlQpbEvra8gyhShYC8RUGaeRQqnzJ5hDKZWNswpPyJkCAPS5d940y0R52DFENowlImuhS+QRgrLPOtTqFvkFNb2TmKRUaVXT9sa9ooGmcb/FsxBLvk0mm0yWqi+LO6FSlQwEfipOTvAVqJNeFFZVbqMbgrZczHZkbaVG6QBHQxw9qZfSWtuY7Iku6HcX6GR1+cKYdfXa4yUwy04afEi978jwV4Q== your_email@example.com

or

docker exec -it devteam key add `cat ~/.ssh/id_rsa.pub`

More in the documentation on command key.

Create a git repository

docker exec -it devteam repo create project

More in the documentation on command repo.

Add the remote repository to your own git repo

git remote add origin git@gitserver:/opt/git/project.git

To get more info to get started with git, you can find a detailed description in https://git-scm.com/book/it/v2/Git-on-the-Server-Setting-Up-the-Server