From 6969795881e7c9863859395171d19bb0f4326506 Mon Sep 17 00:00:00 2001 From: Jerry Aldrich Date: Mon, 20 Jan 2020 14:03:33 -0800 Subject: [PATCH] Initial commit --- .gitignore | 2 ++ Dockerfile | 27 +++++++++++++++++++ README.md | 1 + cgitrc.template | 71 +++++++++++++++++++++++++++++++++++++++++++++++++ entrypoint.sh | 17 ++++++++++++ nginx.conf | 38 ++++++++++++++++++++++++++ 6 files changed, 156 insertions(+) create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 README.md create mode 100644 cgitrc.template create mode 100644 entrypoint.sh create mode 100644 nginx.conf diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..86b9191 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +keys/* +repos/* diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8725f63 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +FROM nginx:alpine + +LABEL maintainer "jerryaldrichiii@gmail.com" + +VOLUME ["/srv/git/repos"] + +RUN apk add --no-cache git fcgiwrap spawn-fcgi highlight py3-markdown py3-docutils py3-pygments + +# nginx:alpine = Alpine 3.11 +RUN apk add --no-cache cgit=1.2.1-r1 + +COPY nginx.conf /etc/nginx/nginx.conf + +# Create group so data can be shared/accessed +RUN addgroup --gid 1000 shared +RUN adduser nginx shared + +EXPOSE 8080 + +COPY cgitrc.template /etc/ +RUN touch /etc/cgitrc && chown nginx:nginx /etc/cgitrc + +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +USER nginx +ENTRYPOINT ["/entrypoint.sh"] diff --git a/README.md b/README.md new file mode 100644 index 0000000..2e4e353 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# cgit diff --git a/cgitrc.template b/cgitrc.template new file mode 100644 index 0000000..e78df66 --- /dev/null +++ b/cgitrc.template @@ -0,0 +1,71 @@ +root-title=$CGIT_TITLE +root-desc=$CGIT_DESC +virtual-root=$CGIT_VROOT +section-from-path=$CGIT_SECTION_FROM_STARTPATH +remove-suffix=1 + +## +## Search for these files in the root of the default branch of repositories +## for coming up with the about page: +## +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 + +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 + +# Cache +cache-root=/var/cache/cgit +cache-size=1000 + +enable-index-links=1 +enable-index-owner=0 +enable-remote-branches=1 +enable-log-filecount=1 +enable-log-linecount=1 +enable-git-config=1 +snapshots=tar.gz tar.bz2 zip + +robots=noindex, nofollow + +source-filter=/usr/lib/cgit/filters/syntax-highlighting.py +about-filter=/usr/lib/cgit/filters/about-formatting.sh +clone-url=git://$CGIT_FQDN/$CGIT_REPO_URL +enable-commit-graph=1 + +# This needs to be at the bottom +# https://linux.die.net/man/5/cgitrc +# > Be advised that only the global settings taken before the scan-path +# > directive will be applied to each repository. +scan-path=/srv/git/repos diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..529a151 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +set -e + +export CGIT_TITLE=${CGIT_TITLE:="TEST TITLE - CHANGE ME"} +export CGIT_DESC=${CGIT_DESC:="TEST DESC"} +export CGIT_VROOT=${CGIT_VROOT:="/"} +export CGIT_FQDN=${CGIT_FQDN:="git.changeme.com"} +export CGIT_SECTION_FROM_STARTPATH=${CGIT_SECTION_FROM_STARTPATH:=1} + +CGIT_VARS='$CGIT_TITLE:$CGIT_DESC:$CGIT_VROOT:$CGIT_SECTION_FROM_STARTPATH' + +envsubst "$CGIT_VARS" < /etc/cgitrc.template > /etc/cgitrc + +/usr/bin/spawn-fcgi -s /tmp/fcgiwrap.socket /usr/bin/fcgiwrap + +/usr/sbin/nginx -g "daemon off;" diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..dee77eb --- /dev/null +++ b/nginx.conf @@ -0,0 +1,38 @@ +worker_processes 1; +pid /tmp/nginx.pid; + +events { + worker_connections 1024; +} + +http { + include mime.types; + default_type application/octet-stream; + sendfile on; + keepalive_timeout 65; + gzip on; + + client_body_temp_path /tmp/client_temp; + proxy_temp_path /tmp/proxy_temp_path; + fastcgi_temp_path /tmp/fastcgi_temp; + uwsgi_temp_path /tmp/uwsgi_temp; + scgi_temp_path /tmp/scgi_temp; + + # Cgit + server { + listen 8080; + server_name git.*; + root /usr/share/webapps/cgit; + try_files $uri @cgit; + + location @cgit { + include fastcgi_params; + # TODO: move fcgiwrap.sock out of /tmp + fastcgi_pass unix:/tmp/fcgiwrap.socket; + fastcgi_param SCRIPT_FILENAME $document_root/cgit.cgi; + fastcgi_param PATH_INFO $uri; + fastcgi_param QUERY_STRING $args; + fastcgi_param HTTP_HOST $server_name; + } + } +}