commit dd2b5933c1cecc03e0a4c141b19daad540e4f637
parent bea544918100fd8ec9c70ecc1ff2b55689eee320
Author: anders <anders@noreply.gitea.andersuno.nu>
Date: Sat, 22 Oct 2022 21:10:18 +0200
readme (#1)
The new and improved README
Co-authored-by: Anders <anders@desk.andersuno.nu>
Diffstat:
M | README.md | | | 85 | ++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------- |
1 file changed, 56 insertions(+), 29 deletions(-)
diff --git a/README.md b/README.md
@@ -5,8 +5,7 @@
- [git-server-docker-stagit](#git-server-docker-stagit)
- [Description](#description)
- - [Main repo](#main-repo)
- - [Gitlab mirror](#gitlab-mirror)
+ - [Mirrors](#mirrors)
- [Credits](#credits)
- [Prerequisites](#prerequisites)
- [Necessary customization](#necessary-customization)
@@ -16,11 +15,12 @@
- [Usage](#usage)
- [Run the container](#run-the-container)
- [Check that container works with your SSH key](#check-that-container-works-with-your-ssh-key)
+ - [Adding persistence to repo and html storage](#adding-persistence-to-repo-and-html-storage)
- [Create a new repo](#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)
+ - [Adding git daemon](#adding-git-daemon)
- [K8S TODO](#k8s-todo)
<!-- markdown-toc end -->
@@ -29,15 +29,13 @@
A lightweight Git Server Docker image built with stagit running Alpine Linux.
Stagit produces static html with every push to a repo.
-A web server container can then be configured to mount that same storage and serve the html.
-Anonymous read-only cloning is enabled via the git daemon on port 9418.
+A web server container can be added to serve that html.
+A git daemon container can be added to enable anonymous read-only cloning.
-### Main repo
+## Mirrors
[https://git.andersuno.nu/git-server-docker-stagit/log.html](https://git.andersuno.nu/git-server-docker-stagit/log.html "git.andersuno.nu")
-### Gitlab mirror
-
[https://gitlab.com/andersuno/git-server-docker-stagit](https://gitlab.com/andersuno/git-server-docker-stagit "gitlab.com")
## Credits
@@ -54,19 +52,26 @@ Forked from jkarlosb [GitHub](https://github.com/jkarlosb/git-server-docker) and
### Optional customization
+* Url line can be deleted entirely if daemon container is not used
+* Both url and owner lines can be deleted entirely if web server container is not used
+ * Line 3 + 9 ./git-shell-commands/new-repo can also be deleted if web server container is not used
* 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
+``` sh
+mkdir ./keys
+cp $HOME/.ssh/id_ed25519.pub ./keys/
+```
+
### Building your image
``` sh
-docker build -t <registry>/<image-name>:<tag> .
+docker build -t localhost/git-server:test ./server_context
```
## Usage
@@ -76,13 +81,15 @@ docker build -t <registry>/<image-name>:<tag> .
Binding to localhost:2222 with keys volume mounted for SSH access.
``` sh
-$ docker run -d -p 2222:22 -v ./keys:/git-server/keys <registry>/<image-name>:<tag>
+docker run -d -p 2222:22 -v ./keys:/git-server/keys localhost/git-server:test
```
### Check that container works with your SSH key
``` sh
-$ ssh git@<ip-docker-server> -p 2222
+ssh git@localhost -p 2222
+```
+```
...
Welcome to git-server-docker!
You've successfully authenticated, but I do not
@@ -90,47 +97,67 @@ provide interactive shell access.
...
```
+### Adding persistence to repo and html storage
+
+For persistence two more volumes need to be mounted.
+
+``` 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 \
+localhost/git-server:test
+```
+
### Create a new repo
``` sh
-$ ssh git@<ip-docker-server> -p 2222 new-repo <repo-name> <repo-description>
+ssh git@localhost -p 2222 new-repo testname testdescription
```
### Clone your new empty repo and start working in it
``` sh
-$ git clone ssh://git@<ip-docker-server>:2222/git-server/repos/<repo-name>.git
+git clone ssh://git@localhost:2222/git-server/repos/testname.git
```
### Upload existing repo into the new empty repo
``` sh
-$ git remote add <remote-name> ssh://git@<ip-docker-server>:2222/git-server/repos/<repo-name>.git
-$ git push <remote-name> <branch name>
+git remote add origin ssh://git@localhost:2222/git-server/repos/testname.git
+git push origin master
```
-* Remote name: often **origin**
-* Branch name: often **master** or **main**
+### Adding web frontend
-### Adding persistence to repo and html storage
+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.
-For persistence two more volumes need to be mounted.
+``` sh
+docker run -d -p 8080:80 -v ./public-html:/usr/share/nginx/html nginx:stable-alpine
+```
+
+### Adding git daemon
+
+To enable anonymous read-only cloning, build the image from
+daemon_context and mount your repos folder when you run the container.
+The git protocol uses port 9418.
``` 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>
+docker build -t localhost/git-daemon:test ./daemon_context
```
-### Adding web frontend
+``` sh
+docker run -d -p 9418:9418 -v ./repos:/git-server/repos localhost/git-daemon:test
+```
-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.
+Clone your previously created testrepo. The git daemon is configured to use
+/git-server/repos as its root, so that part can be left out here.
+Note that this is anonymous, unauthenticated and read only so you cannot push to
+the repo, only pull. And so can anyone with your url.
``` sh
-$ docker run -d -p 8080:80 -v ./public-html:/usr/share/nginx/html nginx:stable-alpine
+git clone git://localhost/testname.git
```
## K8S TODO