git-server-docker-stagit

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

README.md (4284B)


      1 # git-server-docker-stagit
      2 
      3 <!-- markdown-toc start - Don't edit this section. Run M-x markdown-toc-refresh-toc -->
      4 **Table of Contents**
      5 
      6 - [git-server-docker-stagit](#git-server-docker-stagit)
      7     - [Description](#description)
      8         - [Main repo](#main-repo)
      9         - [Gitlab mirror](#gitlab-mirror)
     10     - [Credits](#credits)
     11     - [Prerequisites](#prerequisites)
     12         - [Necessary customization](#necessary-customization)
     13         - [Optional customization](#optional-customization)
     14         - [SSH keys](#ssh-keys)
     15         - [Building your image](#building-your-image)
     16     - [Usage](#usage)
     17         - [Run the container](#run-the-container)
     18         - [Check that container works with your SSH key](#check-that-container-works-with-your-ssh-key)
     19         - [Create a new repo](#create-a-new-repo)
     20         - [Clone your new empty repo and start working in it](#clone-your-new-empty-repo-and-start-working-in-it)
     21         - [Upload existing repo into the new empty repo](#upload-existing-repo-into-the-new-empty-repo)
     22         - [Adding persistence to repo and html storage](#adding-persistence-to-repo-and-html-storage)
     23         - [Adding web frontend](#adding-web-frontend)
     24     - [K8S TODO](#k8s-todo)
     25 
     26 <!-- markdown-toc end -->
     27 
     28 ## Description
     29 
     30 A lightweight Git Server Docker image built with stagit running Alpine Linux.
     31 Stagit produces static html with every push to a repo.
     32 A web server container can then be configured to mount that same storage and serve the html.
     33 Anonymous read-only cloning is enabled via the git daemon on port 9418.
     34 
     35 ### Main repo
     36 
     37 [https://git.andersuno.nu/git-server-docker-stagit/log.html](https://git.andersuno.nu/git-server-docker-stagit/log.html "git.andersuno.nu")
     38 
     39 ### Gitlab mirror
     40 
     41 [https://gitlab.com/andersuno/git-server-docker-stagit](https://gitlab.com/andersuno/git-server-docker-stagit "gitlab.com")
     42 
     43 ## Credits
     44 
     45 Forked from jkarlosb [GitHub](https://github.com/jkarlosb/git-server-docker) and [Docker Hub](https://hub.docker.com/r/jkarlos/git-server-docker/)
     46 
     47 ![image git server docker](git-server-docker.jpg "git server docker")
     48 
     49 ## Prerequisites
     50 
     51 ### Necessary customization
     52 
     53 * Modify line 10 + 11 in ./git-shell-commands/new-repo to echo correct information into "./url" and "./owner"
     54 
     55 ### Optional customization
     56 
     57 * Modify contents of ./resources
     58 * Modify ./sshd_config (Allowing password or root authentication **not** recommended)
     59 * Turn off anonymous read-only cloning
     60 
     61 ### SSH keys
     62 
     63 * Your SSH public key(s) need to be mounted in the container at /git-server/keys/
     64 * Create folder ./keys and copy your id_ed25519.pub or other public key(s) into it
     65 
     66 ### Building your image
     67 
     68 ``` sh
     69 docker build -t <registry>/<image-name>:<tag> .
     70 ```
     71 
     72 ## Usage
     73 
     74 ### Run the container
     75 
     76 Binding to localhost:2222 with keys volume mounted for SSH access.
     77 
     78 ``` sh
     79 $ docker run -d -p 2222:22 -v ./keys:/git-server/keys <registry>/<image-name>:<tag>
     80 ```
     81 
     82 ### Check that container works with your SSH key
     83 
     84 ``` sh
     85 $ ssh git@<ip-docker-server> -p 2222
     86 ...
     87 Welcome to git-server-docker!
     88 You've successfully authenticated, but I do not
     89 provide interactive shell access.
     90 ...
     91 ```
     92 
     93 ### Create a new repo
     94 
     95 ``` sh
     96 $ ssh git@<ip-docker-server> -p 2222 new-repo <repo-name> <repo-description>
     97 ```
     98 
     99 ### Clone your new empty repo and start working in it
    100 
    101 ``` sh
    102 $ git clone ssh://git@<ip-docker-server>:2222/git-server/repos/<repo-name>.git
    103 ```
    104 
    105 ### Upload existing repo into the new empty repo
    106 
    107 ``` sh
    108 $ git remote add <remote-name> ssh://git@<ip-docker-server>:2222/git-server/repos/<repo-name>.git
    109 $ git push <remote-name> <branch name>
    110 ```
    111 
    112 * Remote name: often **origin**
    113 * Branch name: often **master** or **main**
    114 
    115 ### Adding persistence to repo and html storage
    116 
    117 For persistence two more volumes need to be mounted.
    118 
    119 ``` sh
    120 $ mkdir ./{repos,public-html}
    121 $ docker run -d -p 2222:22 -v ./keys:/git-server/keys \
    122 -v ./repos:/git-server/repos -v ./public-html:/git-server/public-html \
    123 <registry>/<image-name>:<tag>
    124 ```
    125 
    126 ### Adding web frontend
    127 
    128 To serve the stagit generated html, start another container that mounts the
    129 same public-html volume as the git-server, into the correct path.
    130 Here I am using nginx from dockerhub binding to localhost:8080.
    131 
    132 ``` sh
    133 $ docker run -d -p 8080:80 -v ./public-html:/usr/share/nginx/html nginx:stable-alpine
    134 ```
    135 
    136 ## K8S TODO