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 (5130B)


      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     - [Mirrors](#mirrors)
      9     - [Credits](#credits)
     10     - [Prerequisites](#prerequisites)
     11         - [Necessary customization](#necessary-customization)
     12         - [Optional customization](#optional-customization)
     13         - [SSH keys](#ssh-keys)
     14         - [Building your image](#building-your-image)
     15     - [Usage](#usage)
     16         - [Run the container](#run-the-container)
     17         - [Check that container works with your SSH key](#check-that-container-works-with-your-ssh-key)
     18         - [Adding persistence to repo and html storage](#adding-persistence-to-repo-and-html-storage)
     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 web frontend](#adding-web-frontend)
     23         - [Adding git daemon](#adding-git-daemon)
     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 be added to serve that html.
     33 A git daemon container can be added to enable anonymous read-only cloning.
     34 
     35 ## Mirrors
     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 [https://gitlab.com/andersuno/git-server-docker-stagit](https://gitlab.com/andersuno/git-server-docker-stagit "gitlab.com")
     40 
     41 ## Credits
     42 
     43 Forked from jkarlosb [GitHub](https://github.com/jkarlosb/git-server-docker) and [Docker Hub](https://hub.docker.com/r/jkarlos/git-server-docker/)
     44 
     45 ![image git server docker](git-server-docker.jpg "git server docker")
     46 
     47 ## Prerequisites
     48 
     49 ### Necessary customization
     50 
     51 * Modify line 10 + 11 in ./git-shell-commands/new-repo to echo correct information into "./url" and "./owner"
     52 
     53 ### Optional customization
     54 
     55 * Url line can be deleted entirely if daemon container is not used
     56 * Both url and owner lines can be deleted entirely if web server container is not used
     57   * Line 3 + 9 ./git-shell-commands/new-repo can also be deleted if web server container is not used
     58 * Modify contents of ./resources
     59 * Modify ./sshd_config
     60   * Allowing password or root authentication **not** recommended
     61   * By default, user git has insecure password 12345 but password authentication is disabled
     62 
     63 ### SSH keys
     64 
     65 * Your SSH public key(s) need to be mounted in the container at /git-server/keys/
     66 * Create folder ./keys and copy your id_ed25519.pub or other public key(s) into it
     67 
     68 ``` sh
     69 mkdir ./keys
     70 cp $HOME/.ssh/id_ed25519.pub ./keys/
     71 ```
     72 
     73 ### Building your image
     74 
     75 ``` sh
     76 docker build -t localhost/git-server:test ./server_context
     77 ```
     78 
     79 ## Usage
     80 
     81 ### Run the container
     82 
     83 Binding to localhost:2222 with keys volume mounted for SSH access.
     84 
     85 ``` sh
     86 docker run -d -p 2222:22 -v ./keys:/git-server/keys localhost/git-server:test
     87 ```
     88 
     89 ### Check that container works with your SSH key
     90 
     91 ``` sh
     92 ssh git@localhost -p 2222
     93 ```
     94 ```
     95 ...
     96 Welcome to git-server-docker!
     97 You've successfully authenticated, but I do not
     98 provide interactive shell access.
     99 ...
    100 ```
    101 
    102 ### Adding persistence to repo and html storage
    103 
    104 For persistence two more volumes need to be mounted.
    105 
    106 ``` sh
    107 mkdir ./{repos,public-html}
    108 docker run -d -p 2222:22 -v ./keys:/git-server/keys \
    109 -v ./repos:/git-server/repos -v ./public-html:/git-server/public-html \
    110 localhost/git-server:test
    111 ```
    112 
    113 ### Create a new repo
    114 
    115 ``` sh
    116 ssh git@localhost -p 2222 new-repo testname testdescription
    117 ```
    118 
    119 ### Clone your new empty repo and start working in it
    120 
    121 ``` sh
    122 git clone ssh://git@localhost:2222/git-server/repos/testname.git
    123 ```
    124 
    125 ### Upload existing repo into the new empty repo
    126 
    127 ``` sh
    128 git remote add origin ssh://git@localhost:2222/git-server/repos/testname.git
    129 git push origin master
    130 ```
    131 
    132 ### Adding web frontend
    133 
    134 To serve the stagit generated html, start another container that mounts the
    135 same public-html volume as the git-server, into the correct path.
    136 Here I am using nginx from dockerhub binding to localhost:8080.
    137 
    138 ``` sh
    139 docker run -d -p 8080:80 -v ./public-html:/usr/share/nginx/html nginx:stable-alpine
    140 ```
    141 
    142 ### Adding git daemon
    143 
    144 To enable anonymous read-only cloning, build the image from
    145 daemon_context and mount your repos folder when you run the container.
    146 The git protocol uses port 9418.
    147 
    148 ``` sh
    149 docker build -t localhost/git-daemon:test ./daemon_context
    150 ```
    151 
    152 ``` sh
    153 docker run -d -p 9418:9418 -v ./repos:/git-server/repos localhost/git-daemon:test
    154 ```
    155 
    156 Clone your previously created testrepo. The git daemon is configured to use
    157 /git-server/repos as its root, so that part can be left out here.
    158 Note that this is anonymous, unauthenticated and read only so you cannot push to
    159 the repo, only pull. And so can anyone with your url.
    160 
    161 ``` sh
    162 git clone git://localhost/testname.git
    163 ```
    164 
    165 ## K8S TODO