aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMitchell Riedstra <mitch@riedstra.dev>2026-01-18 16:45:04 -0500
committerMitchell Riedstra <mitch@riedstra.dev>2026-01-18 16:45:44 -0500
commit037ddb4f29fc2af3ef16a9e51312bde85f635c9b (patch)
tree8e0d3f357d9440b9e740d92a0e53e4ad2a6f7e4e
parentbae5e4768d6afe32659d803fe454ba49ee948031 (diff)
downloadalpine-cgit-master.tar.gz
alpine-cgit-master.tar.xz
Bump to Alpine 3.23HEADmaster
Switch markdown formatting to cmark which is far faster than the old python based setup. Also tweak cgitrc and Nginx configuration a bit for simplicity. Move webroot out of git root.
-rw-r--r--Dockerfile12
-rw-r--r--cgitrc4
-rwxr-xr-xentrypoint.sh22
-rwxr-xr-xformatters/about-formatting.sh32
-rw-r--r--home/.webroot/cgit.css (renamed from home/local/style.css)0
-rw-r--r--home/cgit4
6 files changed, 46 insertions, 28 deletions
diff --git a/Dockerfile b/Dockerfile
index 1849b49..223d979 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -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/
diff --git a/cgitrc b/cgitrc
index e367de7..31505fe 100644
--- a/cgitrc
+++ b/cgitrc
@@ -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
diff --git a/home/cgit b/home/cgit
index 3b19ca4..56eb1ee 100644
--- a/home/cgit
+++ b/home/cgit
@@ -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