diff options
| -rw-r--r-- | .dockerignore | 2 | ||||
| -rw-r--r-- | .gitignore | 2 | ||||
| -rw-r--r-- | Dockerfile | 19 | ||||
| -rw-r--r-- | cgitrc | 64 | ||||
| -rw-r--r-- | docker-compose.yml | 12 | ||||
| -rwxr-xr-x | entrypoint.sh | 173 | ||||
| -rw-r--r-- | home/cgit | 110 | ||||
| -rwxr-xr-x | home/hidden.sh | 7 | ||||
| -rwxr-xr-x | home/hide.sh | 10 | ||||
| -rw-r--r-- | home/local/style.css | 864 | ||||
| -rwxr-xr-x | home/repack.sh | 13 | ||||
| -rw-r--r-- | home/robots.txt | 2 | ||||
| -rwxr-xr-x | home/unhide.sh | 9 | ||||
| -rwxr-xr-x | home/update.sh | 14 | ||||
| -rw-r--r-- | readme.md | 105 | ||||
| -rw-r--r-- | repositories | 2 |
16 files changed, 1408 insertions, 0 deletions
diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..7588ddc --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +hostkeys +homedir diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7588ddc --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +hostkeys +homedir diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..403b4a5 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +FROM alpine:3.12 + +COPY repositories /etc/apk/ + +RUN apk update +RUN apk add fcgiwrap python3 py3-pygments py3-markdown cgit git openssh nginx xz + +# Nice stuff, but not necessary +RUN apk add bash vim + +COPY cgitrc /etc/cgitrc +RUN mkdir -p /var/git + +RUN mkdir -p /var/default/git/ +COPY home/ /var/default/git/ + +COPY entrypoint.sh / + +ENTRYPOINT /entrypoint.sh @@ -0,0 +1,64 @@ +# Allow http transport git clone +#enable-http-clone=0 +enable-http-clone=1 + +# if you do not want that webcrawler (like google) index your site +robots=noindex, nofollow + +# if cgit messes up links, use a virtual-root. For example, cgit.example.org/ has this value: + +virtual-root=/ + +enable-commit-graph=1 +enable-log-filecount=1 +enable-log-linecount=1 +branch-sort=age + +## List of common mimetypes +## + +mimetype.gif=image/gif +mimetype.html=text/html +mimetype.jpg=image/jpeg +mimetype.jpeg=image/jpeg +mimetype.pdf=application/pdf +mimetype.png=image/png +mimetype.svg=image/svg+xml + + +# Highlight source code with python pygments-based highlighter +source-filter=/usr/lib/cgit/filters/syntax-highlighting.py + +about-filter=/usr/lib/cgit/filters/about-formatting.sh + +readme=:README.md +readme=:readme.md +readme=:README.mkd +readme=:readme.mkd +readme=:README.rst +readme=:readme.rst +readme=:README.html +readme=:readme.html +readme=:README.htm +readme=:readme.htm +readme=:README.txt +readme=:readme.txt +readme=:README +readme=:readme +readme=:INSTALL.md +readme=:install.md +readme=:INSTALL.mkd +readme=:install.mkd +readme=:INSTALL.rst +readme=:install.rst +readme=:INSTALL.html +readme=:install.html +readme=:INSTALL.htm +readme=:install.htm +readme=:INSTALL.txt +readme=:install.txt +readme=:INSTALL +readme=:install + +include=/var/git/cgit + diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..3a26619 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,12 @@ +version: '3' +services: + cgit: + build: + context: . + image: cgit + volumes: + - ./homedir:/var/git + - ./hostkeys:/var/hostkeys + ports: + - '127.0.0.1:8080:8080' + - '0.0.0.0:8022:8022' diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..11c2a7e --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,173 @@ +#!/bin/sh +printf "\033[1;31m" +set -e +set -x + +SSHD_PORT="${SSHD_PORT:-8022}" +NGINX_LISTEN="${NGINX_LISTEN:-8080}" +# This is shown on the cgit user interface by default, you may +# wish to change it +FULL_NAME="${FULL_NAME:-Default Cgit User}" +# Bash is installed by default, feel free to change this +CGIT_SHELL="${CGIT_SHELL:-/bin/ash}" +# UID and GID used by the `git` user inside of the container +CGIT_UID="${CGIT_UID:-3500}" +CGIT_GID="${CGIT_GID:-3500}" +# Threads for fcgiwrap +CGIT_THREADS="${CGIT_THREADS:-1}" +# Where the SSH host keys will be stored, +SSH_HOST_KEY_DIR="${SSH_HOST_KEY_DIR:-/var/hostkeys/}" +NGINX_WORKER_PROCESSES="${NGINX_WORKER_PROCESSES:-1}" +NGINX_WORKER_CONNECTIONS="${NGINX_WORKER_CONNECTIONS:-1024}" + +printf "\033[0m" + +setup() { +if [ "$(find /var/git -type f | wc -l)" -eq 0 ] ; then + cp -r /var/default/git/* /var/git/ +fi + +addgroup -g "${CGIT_GID}" git +adduser -h /var/git --gecos "$FULL_NAME" -D -s "${CGIT_SHELL}" -u "${CGIT_UID}" -G git git +chown -R git:git /var/git +passwd -u git + +addgroup nginx git + +if [ -n "$AUTHORIZED_KEYS" ] ; then + mkdir -p /etc/ssh/keys + echo "$AUTHORIZED_KEYS" | tee /etc/ssh/keys/git +fi +} + +# exec runsvdir /var/service +# /var/service/nginx/run & + +run_nginx() { +cat > /etc/nginx/nginx.conf <<NGINX +worker_processes $NGINX_WORKER_PROCESSES; +error_log /dev/fd/2; +events { + worker_connections $NGINX_WORKER_CONNECTIONS; +} +http { + access_log /dev/fd/1; + include mime.types; + default_type application/octet-stream; + sendfile on; + keepalive_timeout 65; + gzip on; + server_tokens off; + server { + listen $NGINX_LISTEN; listen [::]:$NGINX_LISTEN; + root /var/git; + + location /local { + alias /var/git/local; + add_header Cache-Control "public, max-age=604800"; + } + + location / { + try_files \$uri @cgit; + } + + # Serve static files with nginx and allow local files to override + location ~* ^.+(cgit.(css|png)|favicon.ico|robots.txt) { + try_files @webappstatic @overrides; + } + location @webappstatic { + root /usr/share/webapps/cgit; + expires 30d; + } + location @overrides { + root /var/git; + expires 30d; + } + + location @cgit { + gzip off; + fastcgi_param PATH_INFO \$uri; + fastcgi_param QUERY_STRING \$args; + fastcgi_param HTTP_HOST \$server_name; + fastcgi_param CGIT_CONFIG /var/git/cgit; + fastcgi_param SCRIPT_FILENAME /usr/share/webapps/cgit/cgit.cgi; + fastcgi_pass unix:/tmp/cgit/cgit.sock; + } + + # Make go-get work + if (\$arg_go-get = 1) { + return 200 '<meta name="go-import" + content="\$host\$uri git \$scheme://\$host\$uri.git">\\n'; + # content="\$host\$uri git \$scheme://\$host/cgi-bin/cgit.cgi\$uri.git">\\n'; + } + } +} +NGINX + +mkdir -p /run/nginx +nginx -g 'daemon off;' & +} + +run_cgit() { +#!/bin/sh +sockdir=/tmp/cgit +if ! [ -d "$sockdir" ] ; then + mkdir "$sockdir" +fi +chown -R git:git /tmp/cgit +socket="/tmp/cgit/cgit.sock" +if [ -e "$socket" ] ; then + rm "$socket" +fi +umask 007 +# su git -c "fcgiwrap -c$CGIT_THREADS -s \"unix:$socket\" &" +su git -c "fcgiwrap -f -c$CGIT_THREADS -s \"unix:$socket\" &" +} + + +run_sshd() { + if [ -d "$SSH_HOST_KEY_DIR" ] ; then + cp -v "$SSH_HOST_KEY_DIR"/* /etc/ssh/ || echo "" + fi + ssh-keygen -A + if [ -d "$SSH_HOST_KEY_DIR" ] ; then + cp -v /etc/ssh/ssh_host* "$SSH_HOST_KEY_DIR"/ + fi + + cat > /etc/ssh/sshd_config <<SSH_CONFIG +Port $SSHD_PORT +ChallengeResponseAuthentication no +PasswordAuthentication no +AuthorizedKeysFile /etc/ssh/keys/%u .ssh/authorized_keys +GatewayPorts no +X11Forwarding no +SSH_CONFIG + + /usr/sbin/sshd -e -D & +} + +watchServices() { +interval="$1"; shift +while true ; do + for service in nginx fcgiwrap sshd ; do + if ! pgrep "$service" >/dev/null ; then + echo "Service $service has stopped... quitting!" + exit 1 + fi + done + sleep "$interval" +done +} + + +setup +run_nginx +run_cgit +run_sshd + + +set +x +# Bail out if a service stops, poll it every 30 seconds +watchServices 30 +# or if you comment out the above, drop into a shell +# exec /bin/ash "$@" diff --git a/home/cgit b/home/cgit new file mode 100644 index 0000000..3b19ca4 --- /dev/null +++ b/home/cgit @@ -0,0 +1,110 @@ +enable-blame=1 + +# clone-url=https://git.example.com/$CGIT_REPO_URL git@git.home.net:$CGIT_REPO_URL +clone-url=https://git.example.com/$CGIT_REPO_URL + +css=/cgit.css +# logo=/cgit.png + +# Allow http transport git clone +#enable-http-clone=0 +enable-http-clone=1 + +# if you do not want that webcrawler (like google) index your site +robots=noindex, nofollow + +# if cgit messes up links, use a virtual-root. For example, cgit.example.org/ has this value: + +virtual-root=/ + +enable-commit-graph=1 +enable-log-filecount=1 +enable-log-linecount=1 +branch-sort=age + +## List of common mimetypes +## + +mimetype.gif=image/gif +mimetype.html=text/html +mimetype.jpg=image/jpeg +mimetype.jpeg=image/jpeg +mimetype.pdf=application/pdf +mimetype.png=image/png +mimetype.svg=image/svg+xml + + + +# Highlight source code with python pygments-based highlighter +source-filter=/usr/lib/cgit/filters/syntax-highlighting.py + +about-filter=/usr/lib/cgit/filters/about-formatting.sh + +readme=:README.md +readme=:readme.md +readme=:README.mkd +readme=:readme.mkd +readme=:README.rst +readme=:readme.rst +readme=:README.html +readme=:readme.html +readme=:README.htm +readme=:readme.htm +readme=:README.txt +readme=:readme.txt +readme=:README +readme=:readme +readme=:INSTALL.md +readme=:install.md +readme=:INSTALL.mkd +readme=:install.mkd +readme=:INSTALL.rst +readme=:install.rst +readme=:INSTALL.html +readme=:install.html +readme=:INSTALL.htm +readme=:install.htm +readme=:INSTALL.txt +readme=:install.txt +readme=:INSTALL +readme=:install + +# include=/var/git/cgit +# logo=/local/logo.jpg +css=/local/style.css +enable-commit-graph=0 + + +# If you wish to include a different header/footer +# head-include=/var/git/local/head.html +# footer=/var/git/local/footer.html + +section-from-path=1 + + + +snapshots=tar.gz tar.xz zip + +root-title=Example cgit server +root-desc=Some sitewide description + + +# Follow the order in this file first +section-sort=0 +repository-sort=age + +# Scan all the shit +scan-path=/var/git/ + +# include=/home/git/mitch/cgit +# section= Mirror +# include=/home/git/mirror/cgit + +# repo.url=mitch/pinnalce_cart_to_opencart +# repo.path=/home/git/mitch/pinnacle_cart_to_opencart.git/ + +# scan-path=/home/git/ +# section=Mirrored repositories that interest me +# repos.url=mirror/%u +# scan-path=/home/git/mirror/ + diff --git a/home/hidden.sh b/home/hidden.sh new file mode 100755 index 0000000..6e0c529 --- /dev/null +++ b/home/hidden.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +# Shows all hidden repos +find . -iname cgitrc \ + | xargs grep -l -n 'hide=1' \ + | xargs -n1 dirname + diff --git a/home/hide.sh b/home/hide.sh new file mode 100755 index 0000000..1a912d3 --- /dev/null +++ b/home/hide.sh @@ -0,0 +1,10 @@ +#!/bin/sh +set -e +if [ -z "$1" ] ; then + echo "Need to supply a path to the repository to hide" + exit 1 +fi +if [ -e "$1/cgitrc" ]; then + sed -i '/^hide=/d' "$1/cgitrc" +fi +echo "hide=1" >> "$1/cgitrc" diff --git a/home/local/style.css b/home/local/style.css new file mode 100644 index 0000000..b8a0e58 --- /dev/null +++ b/home/local/style.css @@ -0,0 +1,864 @@ +body { + margin: 40px auto; + max-width: 960px; + line-height: 1.6; + font-size: 1em; + color: #444; + padding: 0 10px; + /* Added because some browsers don't default to white */ + background-color: #fff; +} + + +div#cgit { + padding: 0em; + margin: 0em; + font-family: sans-serif; + font-size: 10pt; + color: #333; + background: white; + padding: 4px; +} + +div#cgit a { + color: #0012ff; + text-decoration: none; +} + +div#cgit a:hover { + text-decoration: underline; +} + +div#cgit table { + border-collapse: collapse; +} + +div#cgit table#header { + width: 100%; + margin-bottom: 1em; +} + +div#cgit table#header td.logo { + width: 96px; + vertical-align: top; + /* As much as I want a logo, I'm not sure + * I'm ever going to find one I like + */ + display: none; +} + +div#cgit table#header td.main { + font-size: 250%; + padding-left: 10px; + white-space: nowrap; +} + +div#cgit table#header td.main a { + color: #000; +} + +div#cgit table#header td.form { + text-align: right; + vertical-align: bottom; + padding-right: 1em; + padding-bottom: 2px; + white-space: nowrap; +} + +div#cgit table#header td.form form, +div#cgit table#header td.form input, +div#cgit table#header td.form select { + font-size: 90%; +} + +div#cgit table#header td.sub { + color: #777; + border-top: solid 1px #ccc; + padding-left: 10px; +} + +div#cgit table.tabs { + border-bottom: solid 3px #ccc; + border-collapse: collapse; + margin-top: 2em; + margin-bottom: 0px; + width: 100%; +} + +div#cgit table.tabs td { + padding: 0px 1em; + vertical-align: bottom; +} + +div#cgit table.tabs td a { + padding: 2px 0.75em; + color: #777; + font-size: 110%; +} + +div#cgit table.tabs td a.active { + color: #000; + background-color: #ccc; +} + +div#cgit table.tabs td.form { + text-align: right; +} + +div#cgit table.tabs td.form form { + padding-bottom: 2px; + font-size: 90%; + white-space: nowrap; +} + +div#cgit table.tabs td.form input, +div#cgit table.tabs td.form select { + font-size: 90%; +} + +div#cgit div.path { + margin: 0px; + padding: 5px 2em 2px 2em; + color: #000; + background-color: #eee; +} + +div#cgit div.content { + margin: 0px; + padding: 2em; + border-bottom: solid 3px #ccc; +} + + +div#cgit table.list { + width: 100%; + border: none; + border-collapse: collapse; +} + +div#cgit table.list tr { + background: white; +} + +div#cgit table.list tr.logheader { + background: #eee; +} + +div#cgit table.list tr:nth-child(even) { + background: #f7f7f7; +} + +div#cgit table.list tr:nth-child(odd) { + background: white; +} + +div#cgit table.list tr:hover { + background: #eee; +} + +div#cgit table.list tr.nohover { + background: white; +} + +div#cgit table.list tr.nohover:hover { + background: white; +} + +div#cgit table.list tr.nohover-highlight:hover:nth-child(even) { + background: #f7f7f7; +} + +div#cgit table.list tr.nohover-highlight:hover:nth-child(odd) { + background: white; +} + +div#cgit table.list th { + font-weight: bold; + border-bottom: dashed 1px #888; + padding: 0.1em 0.5em 0.05em 0.5em; + vertical-align: baseline; +} + +div#cgit table.list td { + border: none; + padding: 0.1em 0.5em 0.1em 0.5em; +} + +div#cgit table.list td.commitgraph { + font-family: monospace; + white-space: pre; +} + +div#cgit table.list td.commitgraph .column1 { + color: #a00; +} + +div#cgit table.list td.commitgraph .column2 { + color: #0a0; +} + +div#cgit table.list td.commitgraph .column3 { + color: #aa0; +} + +div#cgit table.list td.commitgraph .column4 { + color: #00a; +} + +div#cgit table.list td.commitgraph .column5 { + color: #a0a; +} + +div#cgit table.list td.commitgraph .column6 { + color: #0aa; +} + +div#cgit table.list td.logsubject { + font-family: monospace; + font-weight: bold; + /* TODO: This needs work... */ + max-width: 50px; + overflow: hidden; + nowrap: unset; +} + +div#cgit table.list td.logmsg { + font-family: monospace; + white-space: pre; + padding: 0 0.5em; +} + +div#cgit table.list td a { + color: black; +} + +div#cgit table.list td a.ls-dir { + font-weight: bold; + color: #0012ff; +} + +div#cgit table.list td a:hover { + color: #0012ff; +} + +div#cgit img { + border: none; +} + +div#cgit input#switch-btn { + margin: 2px 0px 0px 0px; +} + +div#cgit td#sidebar input.txt { + width: 100%; + margin: 2px 0px 0px 0px; +} + +div#cgit table#grid { + margin: 0px; +} + +div#cgit td#content { + vertical-align: top; + padding: 1em 2em 1em 1em; + border: none; +} + +div#cgit div#summary { + vertical-align: top; + margin-bottom: 1em; +} + +div#cgit table#downloads { + float: right; + border-collapse: collapse; + border: solid 1px #777; + margin-left: 0.5em; + margin-bottom: 0.5em; +} + +div#cgit table#downloads th { + background-color: #ccc; +} + +div#cgit div#blob { + border: solid 1px black; +} + +div#cgit div.error { + color: red; + font-weight: bold; + margin: 1em 2em; +} + +div#cgit a.ls-blob, div#cgit a.ls-dir, div#cgit .ls-mod { + font-family: monospace; +} + +div#cgit td.ls-size { + text-align: right; + font-family: monospace; + width: 10em; +} + +div#cgit td.ls-mode { + font-family: monospace; + width: 10em; +} + +div#cgit table.blob { + margin-top: 0.5em; + border-top: solid 1px black; +} + +div#cgit table.blob td.lines { + margin: 0; padding: 0 0 0 0.5em; + vertical-align: top; + color: black; +} + +div#cgit table.blob td.linenumbers { + margin: 0; padding: 0 0.5em 0 0.5em; + vertical-align: top; + text-align: right; + border-right: 1px solid gray; +} + +div#cgit table.blob pre { + padding: 0; margin: 0; +} + +div#cgit table.blob td.linenumbers a, +div#cgit table.ssdiff td.lineno a { + color: gray; + text-align: right; + text-decoration: none; +} + +div#cgit table.blob td.linenumbers a:hover, +div#cgit table.ssdiff td.lineno a:hover { + color: black; +} + +div#cgit table.bin-blob { + margin-top: 0.5em; + border: solid 1px black; +} + +div#cgit table.bin-blob th { + font-family: monospace; + white-space: pre; + border: solid 1px #777; + padding: 0.5em 1em; +} + +div#cgit table.bin-blob td { + font-family: monospace; + white-space: pre; + border-left: solid 1px #777; + padding: 0em 1em; +} + +div#cgit table.nowrap td { + /*! white-space: nowrap; */ +} + +div#cgit table.commit-info { + border-collapse: collapse; + margin-top: 1.5em; +} + +div#cgit div.cgit-panel { + float: right; + margin-top: 1.5em; +} + +div#cgit div.cgit-panel table { + border-collapse: collapse; + border: solid 1px #aaa; + background-color: #eee; +} + +div#cgit div.cgit-panel th { + text-align: center; +} + +div#cgit div.cgit-panel td { + padding: 0.25em 0.5em; +} + +div#cgit div.cgit-panel td.label { + padding-right: 0.5em; +} + +div#cgit div.cgit-panel td.ctrl { + padding-left: 0.5em; +} + +div#cgit table.commit-info th { + text-align: left; + font-weight: normal; + padding: 0.1em 1em 0.1em 0.1em; + vertical-align: top; +} + +div#cgit table.commit-info td { + font-weight: normal; + padding: 0.1em 1em 0.1em 0.1em; +} + +div#cgit div.commit-subject { + font-weight: bold; + font-size: 125%; + margin: 1.5em 0em 0.5em 0em; + padding: 0em; +} + +div#cgit div.commit-msg { + white-space: pre; + font-family: monospace; +} + +div#cgit div.notes-header { + font-weight: bold; + padding-top: 1.5em; +} + +div#cgit div.notes { + white-space: pre; + font-family: monospace; + border: solid 1px #ee9; + background-color: #ffd; + padding: 0.3em 2em 0.3em 1em; + float: left; +} + +div#cgit div.notes-footer { + clear: left; +} + +div#cgit div.diffstat-header { + font-weight: bold; + padding-top: 1.5em; +} + +div#cgit table.diffstat { + border-collapse: collapse; + border: solid 1px #aaa; + background-color: #eee; +} + +div#cgit table.diffstat th { + font-weight: normal; + text-align: left; + text-decoration: underline; + padding: 0.1em 1em 0.1em 0.1em; + font-size: 100%; +} + +div#cgit table.diffstat td { + padding: 0.2em 0.2em 0.1em 0.1em; + font-size: 100%; + border: none; +} + +div#cgit table.diffstat td.mode { + white-space: nowrap; +} + +div#cgit table.diffstat td span.modechange { + padding-left: 1em; + color: red; +} + +div#cgit table.diffstat td.add a { + color: green; +} + +div#cgit table.diffstat td.del a { + color: red; +} + +div#cgit table.diffstat td.upd a { + color: #0012ff; +} + +div#cgit table.diffstat td.graph { + width: 500px; + vertical-align: middle; +} + +div#cgit table.diffstat td.graph table { + border: none; +} + +div#cgit table.diffstat td.graph td { + padding: 0px; + border: 0px; + height: 7pt; +} + +div#cgit table.diffstat td.graph td.add { + background-color: #5c5; +} + +div#cgit table.diffstat td.graph td.rem { + background-color: #c55; +} + +div#cgit div.diffstat-summary { + color: #888; + padding-top: 0.5em; +} + +div#cgit table.diff { + width: 100%; +} + +div#cgit table.diff td { + font-family: monospace; + white-space: pre; +} + +div#cgit table.diff td div.head { + font-weight: bold; + margin-top: 1em; + color: black; +} + +div#cgit table.diff td div.hunk { + color: #009; +} + +div#cgit table.diff td div.add { + color: green; +} + +div#cgit table.diff td div.del { + color: red; +} + +div#cgit .sha1 { + font-family: monospace; + font-size: 90%; +} + +div#cgit .left { + text-align: left; +} + +div#cgit .right { + text-align: right; +} + +div#cgit table.list td.reposection { + font-style: italic; + color: #888; +} + +div#cgit a.button { + font-size: 80%; + padding: 0em 0.5em; +} + +div#cgit a.primary { + font-size: 100%; +} + +div#cgit a.secondary { + font-size: 90%; +} + +div#cgit td.toplevel-repo { + +} + +div#cgit table.list td.sublevel-repo { + padding-left: 1.5em; +} + +div#cgit ul.pager { + list-style-type: none; + text-align: center; + margin: 1em 0em 0em 0em; + padding: 0; +} + +div#cgit ul.pager li { + display: inline-block; + margin: 0.25em 0.5em; +} + +div#cgit ul.pager a { + color: #777; +} + +div#cgit ul.pager .current { + font-weight: bold; +} + +div#cgit span.age-mins { + font-weight: bold; + color: #080; +} + +div#cgit span.age-hours { + color: #080; +} + +div#cgit span.age-days { + color: #040; +} + +div#cgit span.age-weeks { + color: #444; +} + +div#cgit span.age-months { + color: #888; +} + +div#cgit span.age-years { + color: #bbb; +} + +div#cgit span.insertions { + color: #080; +} + +div#cgit span.deletions { + color: #800; +} + +div#cgit div.footer { + margin-top: 0.5em; + text-align: center; + font-size: 80%; + color: #ccc; +} + +div#cgit div.footer a { + color: #ccc; + text-decoration: none; +} + +div#cgit div.footer a:hover { + text-decoration: underline; +} + +div#cgit a.branch-deco { + color: #000; + margin: 0px 0.5em; + padding: 0px 0.25em; + background-color: #88ff88; + border: solid 1px #007700; +} + +div#cgit a.tag-deco { + color: #000; + margin: 0px 0.5em; + padding: 0px 0.25em; + background-color: #ffff88; + border: solid 1px #777700; +} + +div#cgit a.remote-deco { + color: #000; + margin: 0px 0.5em; + padding: 0px 0.25em; + background-color: #ccccff; + border: solid 1px #000077; +} + +div#cgit a.deco { + color: #000; + margin: 0px 0.5em; + padding: 0px 0.25em; + background-color: #ff8888; + border: solid 1px #770000; +} + +div#cgit div.commit-subject a.branch-deco, +div#cgit div.commit-subject a.tag-deco, +div#cgit div.commit-subject a.remote-deco, +div#cgit div.commit-subject a.deco { + margin-left: 1em; + font-size: 75%; +} + +div#cgit table.stats { + border: solid 1px black; + border-collapse: collapse; +} + +div#cgit table.stats th { + text-align: left; + padding: 1px 0.5em; + background-color: #eee; + border: solid 1px black; +} + +div#cgit table.stats td { + text-align: right; + padding: 1px 0.5em; + border: solid 1px black; +} + +div#cgit table.stats td.total { + font-weight: bold; + text-align: left; +} + +div#cgit table.stats td.sum { + color: #c00; + font-weight: bold; +/* background-color: #eee; */ +} + +div#cgit table.stats td.left { + text-align: left; +} + +div#cgit table.vgraph { + border-collapse: separate; + border: solid 1px black; + height: 200px; +} + +div#cgit table.vgraph th { + background-color: #eee; + font-weight: bold; + border: solid 1px white; + padding: 1px 0.5em; +} + +div#cgit table.vgraph td { + vertical-align: bottom; + padding: 0px 10px; +} + +div#cgit table.vgraph div.bar { + background-color: #eee; +} + +div#cgit table.hgraph { + border: solid 1px black; + width: 800px; +} + +div#cgit table.hgraph th { + background-color: #eee; + font-weight: bold; + border: solid 1px black; + padding: 1px 0.5em; +} + +div#cgit table.hgraph td { + vertical-align: middle; + padding: 2px 2px; +} + +div#cgit table.hgraph div.bar { + background-color: #eee; + height: 1em; +} + +div#cgit table.ssdiff { + width: 100%; +} + +div#cgit table.ssdiff td { + font-size: 75%; + font-family: monospace; + white-space: pre; + padding: 1px 4px 1px 4px; + border-left: solid 1px #aaa; + border-right: solid 1px #aaa; +} + +div#cgit table.ssdiff td.add { + color: black; + background: #cfc; + min-width: 50%; +} + +div#cgit table.ssdiff td.add_dark { + color: black; + background: #aca; + min-width: 50%; +} + +div#cgit table.ssdiff span.add { + background: #cfc; + font-weight: bold; +} + +div#cgit table.ssdiff td.del { + color: black; + background: #fcc; + min-width: 50%; +} + +div#cgit table.ssdiff td.del_dark { + color: black; + background: #caa; + min-width: 50%; +} + +div#cgit table.ssdiff span.del { + background: #fcc; + font-weight: bold; +} + +div#cgit table.ssdiff td.changed { + color: black; + background: #ffc; + min-width: 50%; +} + +div#cgit table.ssdiff td.changed_dark { + color: black; + background: #cca; + min-width: 50%; +} + +div#cgit table.ssdiff td.lineno { + color: black; + background: #eee; + text-align: right; + width: 3em; + min-width: 3em; +} + +div#cgit table.ssdiff td.hunk { + color: black; + background: #ccf; + border-top: solid 1px #aaa; + border-bottom: solid 1px #aaa; +} + +div#cgit table.ssdiff td.head { + border-top: solid 1px #aaa; + border-bottom: solid 1px #aaa; +} + +div#cgit table.ssdiff td.head div.head { + font-weight: bold; + color: black; +} + +div#cgit table.ssdiff td.foot { + border-top: solid 1px #aaa; + border-left: none; + border-right: none; + border-bottom: none; +} + +div#cgit table.ssdiff td.space { + border: none; +} + +div#cgit table.ssdiff td.space div { + min-height: 3em; +} + diff --git a/home/repack.sh b/home/repack.sh new file mode 100755 index 0000000..25419ea --- /dev/null +++ b/home/repack.sh @@ -0,0 +1,13 @@ +#!/bin/sh +set -e +set -x + +repos="$(find "$HOME" -type d -iname '*.git')" + +IFS=" +" + +for repo in $repos ; do + cd "$repo" + git repack +done diff --git a/home/robots.txt b/home/robots.txt new file mode 100644 index 0000000..1f53798 --- /dev/null +++ b/home/robots.txt @@ -0,0 +1,2 @@ +User-agent: * +Disallow: / diff --git a/home/unhide.sh b/home/unhide.sh new file mode 100755 index 0000000..beab919 --- /dev/null +++ b/home/unhide.sh @@ -0,0 +1,9 @@ +#!/bin/sh +set -e +if [ -z "$1" ] ; then + echo "Need to supply a path to the repository to unhide" + exit 1 +fi +if [ -e "$1/cgitrc" ]; then + sed -i '/^hide=/d' "$1/cgitrc" +fi diff --git a/home/update.sh b/home/update.sh new file mode 100755 index 0000000..b6a0412 --- /dev/null +++ b/home/update.sh @@ -0,0 +1,14 @@ +#!/bin/sh +set -e +set -x + +repos="$(find $HOME -type d -iname '*.git')" + +IFS=" +" + +for repo in $repos ; do + cd $repo + git update-server-info +done + diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..172112e --- /dev/null +++ b/readme.md @@ -0,0 +1,105 @@ +# Alpine Linux Cgit + +Docker image for running a cgit instance. + +Primarily designed for a single user though it wouldn't be too hard to alter +the [`entrypoint.sh`](entrypoint.sh) to add and support multiple users with +separate keys, permissions and such. + +This runs fastcgiwrap, nginx and a SSH server for a self hosted private +git server. + +Password authentication for SSH is entirely disabled + +## Building + +```shell +$ docker build -t cgit . +``` + +## Configuration + +Mostly by environment variables: + + +```bash +# You can supply authorized keys via environment variables in addition +# to adding them directly to git's home directory `.ssh/authorized_keys` +# AUTHORIZED_KEYS="CHANGEME" +SSHD_PORT="${SSHD_PORT:-8022}" +NGINX_LISTEN="${NGINX_LISTEN:-8080}" +# This is shown on the cgit user interface by default, you may +# wish to change it +FULL_NAME="${FULL_NAME:-Default Cgit User}" +# Bash is installed by default, feel free to change this +CGIT_SHELL="${CGIT_SHELL:-/bin/ash}" +# UID and GID used by the `git` user inside of the container +CGIT_UID="${CGIT_UID:-3500}" +CGIT_GID="${CGIT_GID:-3500}" +# Threads for fcgiwrap +CGIT_THREADS="${CGIT_THREADS:-1}" +# Where the SSH host keys will be stored, +SSH_HOST_KEY_DIR="${SSH_HOST_KEY_DIR:-/var/hostkeys/}" +NGINX_WORKER_PROCESSES="${NGINX_WORKER_PROCESSES:-1}" +NGINX_WORKER_CONNECTIONS="${NGINX_WORKER_CONNECTIONS:-1024}" +``` + +No SSL configuration is provided since it's expected that you will toss +this behind a proxy. + + +## Volumes / persistence + +By default there are no volumes, you will want to specify them for +`/var/git` and `/var/hostkeys` + +`/var/git` is the home directory for git where you should put your +repositories, cgit configuration, scripts and optionally your ssh +keys + +`/var/hostkeys` is where the SSH server's host keys will be stored. +If omitted new host keys will be generated on each run leading to +some scary warnings since SSH is trust on first use and stores the host +keys. + + +## Examples + + +### Calling docker directly + +```shell +$ docker run -it --rm \ + -e CGIT_UID=1000 \ + -e CGIT_GID=1000 \ + -e "AUTHORIZED_KEYS=$(cat ~/.ssh/id_ed25519.pub)" \ + -v $(pwd)/homedir:/var/git \ + -v $(pwd)/hostkeys:/var/hostkeys + cgit +``` + + +### `docker-compose` + + +`docker-compose.yml` +```yaml +version: '3' +services: + cgit: + build: + context: . + image: cgit + volumes: + - ./homedir:/var/git + - ./hostkeys:/var/hostkeys + ports: + - '127.0.0.1:8080:8080' + - '0.0.0.0:8022:8022' +``` + +And then + +```shell +$ docker-compose up -d +``` diff --git a/repositories b/repositories new file mode 100644 index 0000000..1ad9e4f --- /dev/null +++ b/repositories @@ -0,0 +1,2 @@ +http://dl-cdn.alpinelinux.org/alpine/v3.12/main +http://dl-cdn.alpinelinux.org/alpine/v3.12/community |
