diff options
| -rw-r--r-- | Dockerfile | 12 | ||||
| -rw-r--r-- | cgitrc | 4 | ||||
| -rwxr-xr-x | entrypoint.sh | 22 | ||||
| -rwxr-xr-x | formatters/about-formatting.sh | 32 | ||||
| -rw-r--r-- | home/.webroot/cgit.css (renamed from home/local/style.css) | 0 | ||||
| -rw-r--r-- | home/cgit | 4 |
6 files changed, 46 insertions, 28 deletions
@@ -1,19 +1,21 @@ -FROM docker.io/alpine:3.22 +FROM docker.io/alpine:3.23 -RUN echo "http://dl-cdn.alpinelinux.org/alpine/v3.22/main" \ +RUN echo "http://dl-cdn.alpinelinux.org/alpine/v3.23/main" \ > /etc/apk/repositories -RUN echo "http://dl-cdn.alpinelinux.org/alpine/v3.22/community" \ +RUN echo "http://dl-cdn.alpinelinux.org/alpine/v3.23/community" \ >> /etc/apk/repositories RUN apk update -RUN apk add fcgiwrap python3 py3-pygments py3-markdown cgit git openssh nginx xz +RUN apk add fcgiwrap cmark cgit git openssh nginx xz # Nice stuff, but not necessary -RUN apk add bash vim +# RUN apk add bash vim COPY cgitrc /etc/cgitrc RUN mkdir -p /var/git +COPY formatters/about-formatting.sh /usr/lib/cgit/filters/about-formatting.sh + RUN mkdir -p /var/default/git/ COPY home/ /var/default/git/ @@ -27,7 +27,9 @@ mimetype.svg=image/svg+xml # Highlight source code with python pygments-based highlighter -source-filter=/usr/lib/cgit/filters/syntax-highlighting.py +# You will need to adjust the dockerfile to make sure they're installed. +# Also, beware they're *very slow* +# source-filter=/usr/lib/cgit/filters/syntax-highlighting.py about-filter=/usr/lib/cgit/filters/about-formatting.sh diff --git a/entrypoint.sh b/entrypoint.sh index bc46d2b..a8de13d 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -59,30 +59,12 @@ http { 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"; - } - + root /var/git/.webroot; + 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; diff --git a/formatters/about-formatting.sh b/formatters/about-formatting.sh new file mode 100755 index 0000000..bca12c2 --- /dev/null +++ b/formatters/about-formatting.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +# Overriding the one provided by cgit, since it uses slow python markdown +# formatting. We're going to use cmark instead ( https://github.com/commonmark/cmark ) + +# Also, removes support for rst and man pages. + +###################################################################### + +# This may be used with the about-filter or repo.about-filter setting in cgitrc. +# It passes formatting of about pages to differing programs, depending on the usage. + +# Markdown support requires python and markdown-python. +# RestructuredText support requires python and docutils. +# Man page support requires groff. + +# The following environment variables can be used to retrieve the configuration +# of the repository for which this script is called: +# CGIT_REPO_URL ( = repo.url setting ) +# CGIT_REPO_NAME ( = repo.name setting ) +# CGIT_REPO_PATH ( = repo.path setting ) +# CGIT_REPO_OWNER ( = repo.owner setting ) +# CGIT_REPO_DEFBRANCH ( = repo.defbranch setting ) +# CGIT_REPO_SECTION ( = section setting ) +# CGIT_REPO_CLONE_URL ( = repo.clone-url setting ) + +cd "$(dirname $0)/html-converters/" +case "$(printf '%s' "$1" | tr '[:upper:]' '[:lower:]')" in + *.markdown|*.mdown|*.md|*.mkd) exec cmark; ;; + *.htm|*.html) exec cat; ;; + *.txt|*) exec ./txt2html; ;; +esac diff --git a/home/local/style.css b/home/.webroot/cgit.css index b8a0e58..b8a0e58 100644 --- a/home/local/style.css +++ b/home/.webroot/cgit.css @@ -36,7 +36,7 @@ mimetype.svg=image/svg+xml # Highlight source code with python pygments-based highlighter -source-filter=/usr/lib/cgit/filters/syntax-highlighting.py +# source-filter=/usr/lib/cgit/filters/syntax-highlighting.py about-filter=/usr/lib/cgit/filters/about-formatting.sh @@ -71,7 +71,7 @@ readme=:install # include=/var/git/cgit # logo=/local/logo.jpg -css=/local/style.css +css=/cgit.css enable-commit-graph=0 |
