git-server-docker-stagit

git-server-with-stagit
git clone git://git.andersuno.nu/git-server-docker-stagit.git
Log | Files | Refs | README

commit d63aae19037391811baaa05bb8fd83163d4cec60
parent 484678830aed3b5d37979ff1e190c86838584331
Author: andersuno <anders@desk.andersuno.nu>
Date:   Sat, 13 Aug 2022 16:33:20 +0200

Updated README

Diffstat:
MREADME.md | 144++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------
1 file changed, 95 insertions(+), 49 deletions(-)

diff --git a/README.md b/README.md @@ -1,76 +1,122 @@ -# git-server-docker +# git-server-docker-stagit + +<!-- markdown-toc start - Don't edit this section. Run M-x markdown-toc-refresh-toc --> +**Table of Contents** + +- [git-server-docker-stagit](#git-server-docker-stagit) + - [Credits](#credits) + - [Prerequisites](#prerequisites) + - [Necessary customization](#necessary-customization) + - [Optional customization](#optional-customization) + - [SSH keys](#ssh-keys) + - [Building your image](#building-your-image) + - [Usage](#usage) + - [Run the container](#run-the-container) + - [Check that container works with your SSH key](#check-that-container-works-with-your-ssh-key) + - [How to create a new repo](#how-to-create-a-new-repo) + - [Clone your new empty repo and start working in it](#clone-your-new-empty-repo-and-start-working-in-it) + - [Upload existing repo into the new empty repo](#upload-existing-repo-into-the-new-empty-repo) + - [Adding persistence to repo and html storage](#adding-persistence-to-repo-and-html-storage) + - [Adding web frontend](#adding-web-frontend) + - [K8S TODO](#k8s-todo) + +<!-- markdown-toc end --> + +## Credits + A lightweight Git Server Docker image built with Alpine Linux. Forked from jkarlosb [GitHub](https://github.com/jkarlosb/git-server-docker) and [Docker Hub](https://hub.docker.com/r/jkarlos/git-server-docker/) ![image git server docker](git-server-docker.jpg "git server docker") -### Basic Usage +## Prerequisites + +### Necessary customization + +* Modify line 10 + 11 in ./git-shell-commands/new-repo to echo correct information into "./url" and "./owner" + +### Optional customization + +* Modify contents of ./resources +* Modify ./sshd_config (Allowing password or root authentication **not** recommended) +* Turn off anonymous read-only cloning + +### SSH keys + +* Your SSH public key(s) need to be mounted in the container at /git-server/keys/ +* Create folder ./keys and copy your id_ed25519.pub or other public key(s) into it + +### Building your image -How to run the container in port 2222 with two volumes: keys volume for public keys and repos volume for git repositories: +``` sh +docker build -t <registry>/<image-name>:<tag> . +``` - $ docker run -d -p 2222:22 -v ~/git-server/keys:/git-server/keys -v ~/git-server/repos:/git-server/repos jkarlos/git-server-docker +## Usage -How to use a public key: +### Run the container - Copy them to keys folder: - - From host: $ cp ~/.ssh/id_rsa.pub ~/git-server/keys - - From remote: $ scp ~/.ssh/id_rsa.pub user@host:~/git-server/keys - You need restart the container when keys are updated: - $ docker restart <container-id> - -How to check that container works (you must to have a key): +Binding to localhost:2222 with keys volume mounted for SSH access. - $ ssh git@<ip-docker-server> -p 2222 - ... - Welcome to git-server-docker! - You've successfully authenticated, but I do not - provide interactive shell access. - ... +``` sh +$ docker run -d -p 2222:22 -v ./keys:/git-server/keys <registry>/<image-name>:<tag> +``` -How to create a new repo: +### Check that container works with your SSH key - $ cd myrepo - $ git init --shared=true - $ git add . - $ git commit -m "my first commit" - $ cd .. - $ git clone --bare myrepo myrepo.git +``` sh +$ ssh git@<ip-docker-server> -p 2222 +... +Welcome to git-server-docker! +You've successfully authenticated, but I do not +provide interactive shell access. +... +``` -How to upload a repo: +### How to create a new repo - From host: - $ mv myrepo.git ~/git-server/repos - From remote: - $ scp -r myrepo.git user@host:~/git-server/repos +``` sh +$ ssh git@<ip-docker-server> -p 2222 new-repo <repo-name> <repo-description> +``` -How clone a repository: +### Clone your new empty repo and start working in it - $ git clone ssh://git@<ip-docker-server>:2222/git-server/repos/myrepo.git +``` sh +$ git clone ssh://git@<ip-docker-server>:2222/git-server/repos/<repo-name>.git +``` -### Arguments +### Upload existing repo into the new empty repo -* **Expose ports**: 22 -* **Volumes**: - * */git-server/keys*: Volume to store the users public keys - * */git-server/repos*: Volume to store the repositories +``` sh +$ git remote add <remote-name> \ +ssh://git@<ip-docker-server>:2222/git-server/repos/<repo-name>.git +$ git push <remote-name> <branch name> +``` -### SSH Keys +* Remote name: often **origin** +* Branch name: often **master** or **main** -How generate a pair keys in client machine: +### Adding persistence to repo and html storage - $ ssh-keygen -t rsa +For persistence two more volumes need to be mounted. -How upload quickly a public key to host volume: +``` sh +$ mkdir ./{repos,public-html} +$ docker run -d -p 2222:22 -v ./keys:/git-server/keys \ +-v ./repos:/git-server/repos -v ./public-html:/git-server/public-html \ +<registry>/<image-name>:<tag> +``` - $ scp ~/.ssh/id_rsa.pub user@host:~/git-server/keys +### Adding web frontend -### Build Image +To serve the stagit generated html, start another container that mounts the +same public-html volume as the git-server, into the correct path. +Here I am using nginx from dockerhub binding to localhost:8080. -How to make the image: +``` sh +$ docker run -d -p 8080:80 -v ./public-html:/usr/share/nginx/html nginx:stable-alpine +``` - $ docker build -t git-server-docker . - -### Docker-Compose -You can edit docker-compose.yml and run this container with docker-compose: +## K8S TODO - $ docker-compose up -d +---