From 030e0ab9a80c4724c67036133e614e0aee0962e7 Mon Sep 17 00:00:00 2001 From: Dominic Ricottone Date: Fri, 22 Jan 2021 18:31:41 +0000 Subject: [PATCH] Initial commit --- Dockerfile | 22 ++++++++++++ LICENSE.md | 31 ++++++++++++++++ Makefile | 3 ++ README.md | 92 +++++++++++++++++++++++++++++++++++++++++++++++ app/cgit.cgi | 4 +++ cgit.d/cgitrc | 14 ++++++++ cgit.d/repos.list | 4 +++ cgitrc | 43 ++++++++++++++++++++++ 8 files changed, 213 insertions(+) create mode 100644 Dockerfile create mode 100644 LICENSE.md create mode 100644 Makefile create mode 100644 README.md create mode 100755 app/cgit.cgi create mode 100644 cgit.d/cgitrc create mode 100644 cgit.d/repos.list create mode 100644 cgitrc diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..df7251c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +# CGit Dockerfile +# Dominic Ricottone +# BSD 3-Clause + +ARG ALPINE_VERSION=latest + +FROM alpine:${ALPINE_VERSION} + +WORKDIR /app + +COPY cgitrc /etc/cgitrc +COPY cgit.d /etc/cgit.d +COPY app /app + +RUN apk add --update spawn-fcgi fcgiwrap cgit git python3 py3-setuptools py3-pygments py3-markdown dumb-init + +EXPOSE 9000 + +ENTRYPOINT ["/usr/bin/dumb-init", "--"] + +CMD ["spawn-fcgi", "-p", "9000", "-n", "/usr/bin/fcgiwrap"] + diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..41dc2f1 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,31 @@ +BSD 3-Clause License +==================== + +_Copyright (c) 2021, Dominic Ricottone_ +_All rights reserved._ + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e283ad6 --- /dev/null +++ b/Makefile @@ -0,0 +1,3 @@ +build: + docker build --tag cgit --tag dricottone/cgit:latest . + diff --git a/README.md b/README.md new file mode 100644 index 0000000..82c37ac --- /dev/null +++ b/README.md @@ -0,0 +1,92 @@ +# docker-cgit + +A Docker image for running CGit, a simple and fast web frontend to the git +versioning system. See the [project page](https://git.zx2c4.com/cgit/about/) +for details and features. + + +## Build + +``` +make build +``` + + +## Configuration + +Edit `cgit.d/cgitrc`, which follows the +[cgitrc](https://git.zx2c4.com/cgit/tree/cgitrc.5.txt) specification. + +This file (and any additonal files, such as a list of repositories) should be +mounted to `/etc/cgit.d`. + + +## Deploy + +This image depends on an external web server running with CGI support. + +NGINX would be configured as: + +``` +server { + listen 80; + server_name _; + + root /app + try_files $uri @cgit; + + location @cgit { + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME /app/cgit.cgi; + fastcgi_param PATH_INFO $uri; + fastcgi_param QUERY_STRING $args; + fastcgi_param HTTP_HOST $server_name; + fastcgi_pass cgit:9000; + } +} +``` + +Both CGit and NGINX can be spun up in a single `docker-compose.yml` file. This +could look like: + +``` +version: '3.7' +services: + cgit: + container_name: cgit + image: dricottone/cgit:latest + volumes: + - /path/to/your/git/repositories:/var/git:ro + - ./cgit.d:/ext/cgit.d:ro + networks: + - cgit-bridge + nginx: + container_name: nginx + image: nginx:alpine + volumes: + - ./nginx.d:/etc/nginx/conf.d:ro + networks: + - cgit-bridge + ports: + - 80:80 + +networks: + cgit-bridge: + name: cgit-bridge +``` + + +## Scope + +The container is configured without caching and without path scanning. If you +are interested in those features of CGit, consider using this as a starting +point rather than a final product. + + +## Licensing + +The Dockerfile is licensed under BSD 3-Clause. There are many more pieces of +software involved in the actual build and deploy processes, all under separate +and disparate licenses. + + diff --git a/app/cgit.cgi b/app/cgit.cgi new file mode 100755 index 0000000..2118178 --- /dev/null +++ b/app/cgit.cgi @@ -0,0 +1,4 @@ +#!/bin/sh + +/usr/share/webapps/cgit/cgit.cgi + diff --git a/cgit.d/cgitrc b/cgit.d/cgitrc new file mode 100644 index 0000000..6d8e8ac --- /dev/null +++ b/cgit.d/cgitrc @@ -0,0 +1,14 @@ +root-title=Index Title +root-desc=Index Tagline +clone-url=http://git.example.com/$CGIT_REPO_URL + +css= +logo= +favicon= + +#header=/etc/cgit.d/header.html +#head-include=/etc/cgit.d/head.html +#footer=/etc/cgit.d/footer.html + +#include=/etc/cgit.d/repos.list + diff --git a/cgit.d/repos.list b/cgit.d/repos.list new file mode 100644 index 0000000..c01309f --- /dev/null +++ b/cgit.d/repos.list @@ -0,0 +1,4 @@ +repo.url=A Pretty Name +repo.path=/path/to/repository +repo.desc=A short (80 character max) description of this repository + diff --git a/cgitrc b/cgitrc new file mode 100644 index 0000000..74ce9f5 --- /dev/null +++ b/cgitrc @@ -0,0 +1,43 @@ +# cgitrc + +# settings +#branch-sort=name +local-time=1 +#max-atom-items=10 +#max-blob-size=0 +#max-commit-count=50 +#max-message-length=80 +#max-repo-count=50 +#max-repodesc-length=80 +#max-stats= +readme=:README.md +#repository-sort=name +#robots=noindex,nofollow +#section-sort=1 +#summary-branches=10 +#summary-log=10 +#summary-tags=10 +virtual-root=/ + +# cgit features +#enable-commit-graph=0 +#enable-filter-overrides=0 +#enable-follow-links=0 +#enable-git-config=0 +#enable-http-clone=1 +#enable-html-serving=0 +#enable-index-links=0 +enable-index-owner=0 +enable-log-filecount=1 +enable-log-linecount=1 +#enable-remote-branches=0 +#enable-subject-links=0 +#enable-tree-linenumbers=1 + +# filter scripts +about-filter=/usr/lib/cgit/filters/about-formatting.sh +source-filter=/usr/lib/cgit/filters/syntax-highlighting.py + +# local configurations +include=/etc/cgit.d/cgitrc + -- 2.45.2