From db228bf139b670789972ffb6a00595c4dbca0c0b Mon Sep 17 00:00:00 2001 From: onelin Date: Tue, 7 Jul 2026 21:59:12 +0200 Subject: Cleanup and minor fixes --- README.md | 5 ++++- gitolite/Dockerfile | 34 ++++++++++++++-------------------- gitolite/cgit/cgitrc | 5 ++--- gitolite/cgit/css_variable_colors.sh | 3 +++ 4 files changed, 23 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index e4d319f..53e925c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,9 @@ # githost -A docker-compose provisioned gitolite+cgit+nginx setup. +A docker-compose provisioned gitolite+cgit+nginx+fail2ban setup. + +It makes it easy to spin up an instance with a nice web interface without the +modern social-media features that ruins modern open source development. ## Setup diff --git a/gitolite/Dockerfile b/gitolite/Dockerfile index 44af1f0..cdb1c7a 100644 --- a/gitolite/Dockerfile +++ b/gitolite/Dockerfile @@ -2,7 +2,8 @@ FROM alpine:3.23.3 AS build RUN set -x \ - && apk add --no-cache gcc g++ cmake make curl linux-headers musl-dev zlib-dev libressl-dev libintl musl-libintl + && apk add --no-cache gcc g++ cmake make curl linux-headers musl-dev zlib-dev \ + libressl-dev libintl musl-libintl # Compile cgit RUN set -x \ @@ -11,10 +12,6 @@ RUN set -x \ && make -C /cgit-1.3 get-git \ && DESTDIR=/pkg NO_REGEX=NeedsStartEnd make -C /cgit-1.3 install - - #&& tar -czvf deps.tar.gz -C /cgit-1.3/pkg . - - # Compile cmark-gfm RUN set -x \ && wget https://github.com/github/cmark-gfm/archive/refs/tags/0.29.0.gfm.13.tar.gz \ @@ -46,25 +43,30 @@ RUN apk update \ COPY cgit/40-fcgiwrap.sh /docker-entrypoint.d/ RUN chmod +x /docker-entrypoint.d/40-fcgiwrap.sh -COPY cgit/cgitrc /etc/ - COPY cgit/nginx.conf / RUN sed "s/\$DOMAIN/$DOMAIN/g" /nginx.conf > /etc/nginx/http.d/default.conf \ && rm /nginx.conf RUN addgroup nginx www-data -COPY cgit/about.html /var/www/htdocs/cgit/ -COPY cgit/cgit.png /var/www/htdocs/cgit/logo.png +COPY cgit/about.html /var/www/htdocs/cgit/ +COPY cgit/cgit.png /var/www/htdocs/cgit/logo.png COPY cgit/favicon.ico /var/www/htdocs/cgit/ COPY cgit/css_variable_colors.sh / +COPY cgit/update_syntax_style.py / COPY cgit/everforest.css /var/www/htdocs/cgit/ -RUN sh css_variable_colors.sh +RUN sh css_variable_colors.sh \ + && python update_syntax_style.py zenburn > /var/www/htdocs/cgit/syntax.css \ + && sed -i -Ee '/^sys\.stdout\.write.*style.*/d' /usr/local/lib/cgit/filters/syntax-highlighting.py COPY cgit/about-formatting.sh /usr/local/lib/cgit/filters/about-formatting.sh RUN chmod 755 /usr/local/lib/cgit/filters/about-formatting.sh +# Lastly copy cgitrc, better to have it later so we don't invalidate the whole +# build cache when iterating... +COPY cgit/cgitrc /etc/ + # Volume used to store SSH host keys, generated on first run VOLUME /etc/ssh/keys @@ -74,16 +76,8 @@ RUN rc-update add fail2ban \ && rc-update add sshd # www-data may not be necessary -RUN addgroup fcgiwrap git -#RUN usermod -G nginx,www-data,git nginx -# Configure gitolite -# Install OpenSSH server and Gitolite -# Unlock the automatically-created git user - -#RUN addgroup -g 102 -S git \ -# && adduser -S -D -H -u 102 -h /var/lib/git -s /sbin/nologin -G git -g git git - -RUN git config --system advice.defaultBranchName false +RUN addgroup fcgiwrap git \ + && git config --system advice.defaultBranchName false # Volume used to store all Gitolite data (keys, config and repositories), initialized on first run VOLUME /var/lib/git diff --git a/gitolite/cgit/cgitrc b/gitolite/cgit/cgitrc index cbfa6a9..e399f79 100644 --- a/gitolite/cgit/cgitrc +++ b/gitolite/cgit/cgitrc @@ -19,14 +19,12 @@ remove-suffix=1 readme=:README.md about-filter=/usr/local/lib/cgit/filters/about-formatting.sh +source-filter=/usr/local/lib/cgit/filters/syntax-highlighting.py # Needs to be mountpoint of the gitolite volume project-list=/var/lib/git/projects.list scan-path=/var/lib/git/repositories -# Requires python -#source-filter=/usr/lib/cgit/filters/syntax-high.py - root-title=Personal projects root-desc=A brief collection root-readme=/var/www/htdocs/cgit/about.html @@ -34,4 +32,5 @@ local-time=1 css=/everforest.css css=/cgit.css +css=/syntax.css logo=/logo.png diff --git a/gitolite/cgit/css_variable_colors.sh b/gitolite/cgit/css_variable_colors.sh index fbab0cc..ef0346f 100644 --- a/gitolite/cgit/css_variable_colors.sh +++ b/gitolite/cgit/css_variable_colors.sh @@ -33,3 +33,6 @@ sed -i -Ee 's/#444\>/var(--color-yellow)/g' "${CGIT_CSS_PATH}" sed -i -Ee 's/#888\>/var(--color-bg-yellow)/g' "${CGIT_CSS_PATH}" # ago, years sed -i -Ee 's/#bbb\>/var(--color-grey)/g' "${CGIT_CSS_PATH}" + +# Change the arrow/link on linenumbers to a `#` +sed -i -Ee 's/\\2BA9/#/g' "${CGIT_CSS_PATH}" -- cgit v1.3