~dricottone/docker-cgit

030e0ab9a80c4724c67036133e614e0aee0962e7 — Dominic Ricottone 3 years ago
Initial commit
8 files changed, 213 insertions(+), 0 deletions(-)

A Dockerfile
A LICENSE.md
A Makefile
A README.md
A app/cgit.cgi
A cgit.d/cgitrc
A cgit.d/repos.list
A cgitrc
A  => Dockerfile +22 -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"]


A  => LICENSE.md +31 -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.


A  => Makefile +3 -0
@@ 1,3 @@
build:
	docker build --tag cgit --tag dricottone/cgit:latest .


A  => README.md +92 -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.



A  => app/cgit.cgi +4 -0
@@ 1,4 @@
#!/bin/sh

/usr/share/webapps/cgit/cgit.cgi


A  => cgit.d/cgitrc +14 -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


A  => cgit.d/repos.list +4 -0
@@ 1,4 @@
repo.url=A Pretty Name
repo.path=/path/to/repository
repo.desc=A short (80 character max) description of this repository 


A  => cgitrc +43 -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