diff options
| author | RATDAD <lambda@disroot.org> | 2025-12-19 02:13:32 -0500 |
|---|---|---|
| committer | RATDAD <lambda@disroot.org> | 2025-12-19 02:13:32 -0500 |
| commit | 714cb1569999b4a51c8bfd24b17736f82f64100c (patch) | |
| tree | 6735e6d52347756bc6e313bbc81e2c80eea4d549 | |
| parent | 50f0b6075edb49ffc09090d0ee71391f44c64daf (diff) | |
| download | cgit-docker-master.tar.gz cgit-docker-master.tar.bz2 cgit-docker-master.zip | |
| -rw-r--r-- | .gitignore | 4 | ||||
| -rw-r--r-- | Dockerfile | 14 | ||||
| -rw-r--r-- | TODO | 5 | ||||
| -rw-r--r-- | entrypoint.sh | 24 | ||||
| -rw-r--r-- | etc/cgitrc | 6 | ||||
| -rw-r--r-- | etc/httpd/conf/httpd.conf | 4 | ||||
| -rw-r--r-- | opt/highlight.sh | 25 |
7 files changed, 31 insertions, 51 deletions
@@ -1,2 +1,4 @@ # Don't include the test files -srv/*
\ No newline at end of file +srv/ +srv/* +.editorconfig @@ -1,6 +1,6 @@ # # -# docker-cgit Docker Container +# cgit-docker Docker Container ################### # Build Stage ################### @@ -31,13 +31,16 @@ LABEL MAINTAINER="RATDAD <lambda@disroot.org>" # Runtime dependencies RUN dnf -y update && dnf -y install \ - httpd git highlight \ + httpd git highlight pip groff \ openssl zlib zip \ && dnf clean all # Install cgit artifacts. COPY --from=builder /build/install / +# Install formatting tools +RUN pip install pygments catppuccin[pygments] markdown docutils + # If set to 0, the container will not \ # handle git-http-backend for you. ENV GIT_HTTP_MODE=0 @@ -52,13 +55,6 @@ ADD etc/httpd/conf.d/git-http-cf.conf /etc/httpd/conf.d/git-http-cf.conf ADD etc/httpd/conf.d/git-http-pcf.conf /etc/httpd/conf.d/git-http-pcf.conf ADD etc/httpd/conf.d/git-http-apcf.conf /etc/httpd/conf.d/git-http-apcf.conf -# Add helper scripts. -COPY opt/ /opt -RUN chmod +x /opt/* - -# Prevent git-http-backend safe.directory errors. -RUN git config --system --add safe.directory /srv/git - # Entrypoint. COPY ./entrypoint.sh / RUN chmod +x /entrypoint.sh @@ -0,0 +1,5 @@ +-- TODO -- + +1. Fix man2html and rst2html scripting. The OG version is WRONG. +2. Create a README. +3. Theming? diff --git a/entrypoint.sh b/entrypoint.sh index c00077f..021b8ca 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,11 +1,10 @@ #!/bin/bash set -e -export GIT_HTTP_MODE="${GIT_HTTP_MODE:-0}" # Default: disabled -export GIT_HTTP_AUTH=0 # whether http auth is enabled for git-http-backend -export GIT_HTTP_AUTH_FILE="${GIT_HTTP_AUTH_FILE:-/srv/git/.htpasswd}" -# Explicitly override for single .htpasswd for cgit/git-http-server -# GIT_HTTP_AUTH_FILE=/srv/www/htdocs/cgit/.htpasswd +export GIT_HTTP_MODE=${GIT_HTTP_MODE:-0} # This is whether git-http-backend is enabled. Default: disabled +export GIT_HTTP_AUTH=0 # This is whether git-http-backend comes with http basic auth. Default: disabled +export GIT_HTTP_AUTH_FILE="${GIT_HTTP_AUTH_FILE:-/srv/git/.htpasswd}" # htpasswd location + CONF_DIR="/etc/httpd/conf.d" ACTIVE_CONF="${CONF_DIR}/git-http.conf" @@ -13,28 +12,28 @@ ACTIVE_CONF="${CONF_DIR}/git-http.conf" rm -f "${ACTIVE_CONF}" # HTTP BASIC AUTH FOR GIT -# Options are 0=disable -# 1=push only, 2=clone/fetch only, -# 3=push,clone/fetch, 4=push,clone/fetch w/auth +# Options are 1=push only, 2=clone/fetch only, \ +# 3=push,clone/fetch, 4=push,clone/fetch (auth for both) \ +# Default: 0 = Disabled case "${GIT_HTTP_MODE}" in 0) ;; 1) ln -s "${CONF_DIR}/git-http-p.conf" "${ACTIVE_CONF}" - echo "Using [git-http] Using Mode 1: git push (auth)" + echo "Using [git-http] Using Mode 1: Authenticated Pushing Enabled" GIT_HTTP_AUTH=1 ;; 2) ln -s "${CONF_DIR}/git-http-cf.conf" "${ACTIVE_CONF}" - echo "[git-http] Using Mode 2: git clone/fetch only (no auth)" + echo "[git-http] Using Mode 2: Unauthenticated Cloning/Fetching Enabled" ;; 3) ln -s "${CONF_DIR}/git-http-pcf.conf" "${ACTIVE_CONF}" - echo "[git-http] Using Mode 3: git push (auth) + git clone/fetch (no auth)" + echo "[git-http] Using Mode 3: Authenticated Pushing + Unauthenticated Cloning/Fetching Enabled" GIT_HTTP_AUTH=1 ;; 4) ln -s "${CONF_DIR}/git-http-apcf.conf" "${ACTIVE_CONF}" - echo "[git-http] Using Mode 4: git push + git clone/fetch (auth)" + echo "[git-http] Using Mode 4: Authenticated Pushing, Cloning and Fetching Enabled" GIT_HTTP_AUTH=1 ;; *) @@ -65,6 +64,7 @@ if [ "$GIT_HTTP_AUTH" -eq 1 ]; then chmod 640 "$GIT_HTTP_AUTH_FILE" fi +# # HTTP BASIC AUTH FOR CGIT if [ -n "$HTTP_AUTH_PASSWORD" ]; then HTTP_AUTH_USER="${HTTP_AUTH_USER:-admin}" @@ -7,7 +7,9 @@ # Global Settings robots=noindex, nofollow snapshots=tar.gz tar.bz2 zip -source-filter=/opt/highlight.sh +source-filter=/usr/local/lib/cgit/filters/syntax-highlighting.py +about-filter=/usr/local/lib/cgit/filters/about-formatting.py +commit-filter=/usr/local/lib/cgit/fiters/commit-links.sh # Assets css=/cgit.css @@ -73,4 +75,4 @@ readme=:install # Don't change. virtual-root=/ -scan-path=/srv/git
\ No newline at end of file +scan-path=/srv/git diff --git a/etc/httpd/conf/httpd.conf b/etc/httpd/conf/httpd.conf index 675241d..5d20569 100644 --- a/etc/httpd/conf/httpd.conf +++ b/etc/httpd/conf/httpd.conf @@ -74,10 +74,10 @@ DocumentRoot "/srv/www/htdocs/cgit" AllowOverride All RewriteEngine On - + # Hard stop: never rewrite Git HTTP requests. RewriteRule ^.+/(git-upload-pack|git-receive-pack|info/refs)$ - [END] - + # Serve static files directly. RewriteCond %{REQUEST_FILENAME} -f RewriteRule ^ - [END] diff --git a/opt/highlight.sh b/opt/highlight.sh deleted file mode 100644 index d9e0ace..0000000 --- a/opt/highlight.sh +++ /dev/null @@ -1,25 +0,0 @@ -# -# -# Syntax Highlighting -# You should mount your own (most likely better) syntax script here. - -BASENAME="$1" -EXTENSION="${BASENAME##*.}" - -[ "${BASENAME}" = "${EXTENSION}" ] && EXTENSION=txt -[ -z "${EXTENSION}" ] && EXTENSION=txt - -[ "${BASENAME%%.*}" = "Makefile" ] && EXTENSION=mk - -# User note: highlight v2 and v3 have different command options. -# -X is replaced by "-O xhtml" in v3. - -# If for whatever reason, this container is using EPEL5 (it shouldn't), -# use the following line instead of the bottom line. -# exec highlight --force -f -I -X -S "$EXTENSION" 2>/dev/null - -# EPEL6 version with no inline css -# exec highlight --force -f -I -O xhtml -S "EXTENSION" 2>/dev/null - -# highlight v3 is available on EPEL6. -exec highlight --force --inline-css -f -I -O xhtml -S "EXTENSION" 2>/dev/null
\ No newline at end of file |
