aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoronelin <oscar@nelin.dk>2026-04-02 17:39:35 +0000
committeronelin <oscar@nelin.dk>2026-04-02 17:42:50 +0000
commitf458a536ac8d732e47a8dce4d92aa2f1b5a2c649 (patch)
tree7f1c538d01d55ab5bddb543eb28364dc3d790914
parent2489faf7ac22f45ab92545db1216ce8cfa4fae98 (diff)
Add compiled cgit 1.3
Also includes: * Everforest theme * Automatic last-modified hooks * Update to icon and logo
-rw-r--r--.gitignore4
-rw-r--r--cgit/Dockerfile35
-rw-r--r--cgit/about.html4
-rw-r--r--cgit/cgit.pngbin0 -> 1462 bytes
-rw-r--r--cgit/cgitrc25
-rw-r--r--cgit/css_variable_colors.sh30
-rw-r--r--cgit/everforest.css49
-rw-r--r--cgit/favicon.pngbin0 -> 6713 bytes
-rw-r--r--cgit/nginx.conf (renamed from cgit/site.template)4
-rw-r--r--docker-compose.yml3
-rw-r--r--gitolite/Dockerfile6
-rw-r--r--gitolite/docker-entrypoint.sh6
-rw-r--r--gitolite/post-receive9
-rw-r--r--init.sh4
14 files changed, 169 insertions, 10 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..96263a2
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+*
+!*.*
+.env
+*.pub
diff --git a/cgit/Dockerfile b/cgit/Dockerfile
index e89b8d3..007fe23 100644
--- a/cgit/Dockerfile
+++ b/cgit/Dockerfile
@@ -1,8 +1,27 @@
+FROM nginx:1.29.7-alpine-slim AS build
+
+RUN set -x \
+ && apk add --no-cache gcc make curl linux-headers musl-dev zlib-dev libressl-dev libintl musl-libintl
+
+RUN wget 'https://git.zx2c4.com/cgit/snapshot/cgit-1.3.tar.xz' \
+ && tar -xvf cgit-1.3.tar.xz
+
+WORKDIR /cgit-1.3
+RUN make get-git \
+ && DESTDIR=pkg NO_REGEX=NeedsStartEnd make install
+
+WORKDIR /cgit-1.3/pkg
+RUN tar -czvf cgit-1.3.tar.gz .
+
+
FROM nginx:1.29.7-alpine-slim
+COPY --from=build /cgit-1.3/pkg/cgit-1.3.tar.gz /cgit-1.3.tar.gz
+
ARG DOMAIN=localhost
RUN set -x \
- && apk add --no-cache cgit fcgiwrap envsubst
+ && apk add --no-cache fcgiwrap envsubst \
+ && tar -xvf /cgit-1.3.tar.gz
RUN apk update && apk update
@@ -11,12 +30,20 @@ RUN chmod +x /docker-entrypoint.d/40-fcgiwrap.sh
COPY cgitrc /etc/
-COPY site.template /
-RUN sed "s/\$DOMAIN/$DOMAIN/g" /site.template > /etc/nginx/conf.d/default.conf
-RUN rm /site.template
+COPY nginx.conf /
+RUN sed "s/\$DOMAIN/$DOMAIN/g" /nginx.conf > /etc/nginx/conf.d/default.conf
+RUN rm /nginx.conf
RUN addgroup nginx www-data
+COPY about.html /var/www/htdocs/cgit/
+COPY cgit.png /var/www/htdocs/cgit/logo.png
+COPY favicon.ico /var/www/htdocs/cgit/
+
+COPY css_variable_colors.sh /
+COPY everforest.css /var/www/htdocs/cgit/
+RUN sh css_variable_colors.sh
+
#RUN sed -i -Ee 's/pid\s+.*;/pid \/tmp\/nginx.pid;/' /etc/nginx/nginx.conf
#RUN sed -i -Ee 's/error_log\s+.*;/error_log \/dev\/stdout;/' /etc/nginx/nginx.conf
#
diff --git a/cgit/about.html b/cgit/about.html
new file mode 100644
index 0000000..ede0cb5
--- /dev/null
+++ b/cgit/about.html
@@ -0,0 +1,4 @@
+<h2>Disclaimer</h2>
+I request that none of this code, in part or in full, be hosted on Github,
+Sourceforge, or any other proprietary platform. This request is made out of
+respect for both me, the developer and for you, the user.
diff --git a/cgit/cgit.png b/cgit/cgit.png
new file mode 100644
index 0000000..65cb7da
--- /dev/null
+++ b/cgit/cgit.png
Binary files differ
diff --git a/cgit/cgitrc b/cgit/cgitrc
index ecd0083..6abeaf5 100644
--- a/cgit/cgitrc
+++ b/cgit/cgitrc
@@ -1,7 +1,28 @@
# Needed to avoid duplicating URI in every href
virtual-root=/
+# Enable us "ignoring" specific repositories
+enable-git-config=1
+
+# Self explanatory
+enable-http-clone=1
+
+# Remove .git suffix
+remove-suffix=1
+
+# Needs to be mountpoint of the gitolite volume
scan-path=/var/lib/git/repositories
project-list=/var/lib/git/projects.list
-#enable-index-links=1
-repo.ignore=1
+
+# Requires python
+#source-filter=/usr/lib/cgit/filters/syntax-high.py
+#about-filter=/usr/lib/cgit/filters/about-formatting.sh
+
+root-title=Personal projects
+root-desc=A brief collection
+root-readme=/var/www/htdocs/cgit/about.html
+local-time=1
+
+css=/everforest.css
+css=/cgit.css
+logo=/logo.png
diff --git a/cgit/css_variable_colors.sh b/cgit/css_variable_colors.sh
new file mode 100644
index 0000000..9ef2818
--- /dev/null
+++ b/cgit/css_variable_colors.sh
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+CGIT_CSS_PATH=/var/www/htdocs/cgit/cgit.css
+sed -i -Ee 's/\<white\>/var(--color-bg)/g' "${CGIT_CSS_PATH}"
+sed -i -Ee 's/\<blue\>/var(--color-accent)/g' "${CGIT_CSS_PATH}"
+sed -i -Ee 's/\<black\>/var(--color-fg)/g' "${CGIT_CSS_PATH}"
+sed -i -Ee 's/#333\>/var(--color-fg)/g' "${CGIT_CSS_PATH}"
+
+sed -i -Ee 's/#ccc\>/var(--color-white-dim)/g' "${CGIT_CSS_PATH}"
+sed -i -Ee 's/#000\>/var(--color-fg-bright)/g' "${CGIT_CSS_PATH}"
+
+sed -i -Ee 's/#777\>/var(--color-white-dim)/g' "${CGIT_CSS_PATH}"
+sed -i -Ee 's/#f7f7f7\>/var(--color-bg-bright)/g' "${CGIT_CSS_PATH}"
+
+sed -i -Ee 's/#eee\>/var(--color-black-bright)/g' "${CGIT_CSS_PATH}"
+
+# links
+sed -i -Ee 's/#00f\>/var(--color-accent)/g' "${CGIT_CSS_PATH}"
+
+# ago, minutes, hours
+sed -i -Ee 's/#080\>/var(--color-green)/g' "${CGIT_CSS_PATH}"
+# ago, days
+sed -i -Ee 's/#040\>/var(--color-green-bright)/g' "${CGIT_CSS_PATH}"
+# ago, weeks
+sed -i -Ee 's/#444\>/var(--color-yellow)/g' "${CGIT_CSS_PATH}"
+# ago, months
+sed -i -Ee 's/#888\>/var(--color-yellow-bright)/g' "${CGIT_CSS_PATH}"
+# ago, years
+sed -i -Ee 's/#bbb\>/var(--color-white)/g' "${CGIT_CSS_PATH}"
+
diff --git a/cgit/everforest.css b/cgit/everforest.css
new file mode 100644
index 0000000..60c64f3
--- /dev/null
+++ b/cgit/everforest.css
@@ -0,0 +1,49 @@
+:root {
+
+ /* Regular */
+ --color-black: #1e2326;
+ --color-red: #e67e80;
+ --color-green: #a7c080;
+ --color-yellow: #dbbc7f;
+ --color-blue: #7fbbb3;
+ --color-purple: #d699b6;
+ --color-turquoise: #7fbbb3;
+ --color-white: #d3c6aa;
+
+ /* Bright */
+ --color-black-bright: #4f5b58;
+ --color-red-bright: #e66868;
+ --color-green-bright: #93b259;
+ --color-yellow-bright: #dfa000;
+ --color-blue-bright: #3a94c5;
+ --color-purple-bright: #df69ba;
+ --color-turquoise-bright: #3a94c5;
+ --color-white-bright: #ffffff;
+
+ --color-white-dim: #7a8478;
+
+
+ --color-fg: #d3c6aa;
+ --color-bg: #3c4841; /*#272e33;*/
+ --color-fg-bright: #fff;
+ --color-bg-bright: #374145;
+ --color-fg-sel: #fff;
+ --color-bg-sel: #414b50;
+
+ --color-accent: var(--color-green);
+ --color-header: var(--color-accent);
+ --color-list-point: var(--color-accent);
+
+ --color-var(--color-blue):
+}
+
+body {
+ background-color: var(--color-bg);
+ color: var(--color-fg);
+}
+
+div#cgit table.tabs td.form input,
+div#cgit table.tabs td.form select {
+ background-color: var(--color-bg-bright);
+ color: var(--color-fg-bright);
+}
diff --git a/cgit/favicon.png b/cgit/favicon.png
new file mode 100644
index 0000000..da6269e
--- /dev/null
+++ b/cgit/favicon.png
Binary files differ
diff --git a/cgit/site.template b/cgit/nginx.conf
index c1962d9..7b03929 100644
--- a/cgit/site.template
+++ b/cgit/nginx.conf
@@ -7,12 +7,12 @@ server {
access_log /var/log/nginx/cgit-access.log;
error_log /var/log/nginx/cgit-error.log;
- root /usr/share/webapps/cgit;
+ root /var/www/htdocs/cgit;
try_files $uri @cgit;
location @cgit {
include fastcgi_params;
- fastcgi_param SCRIPT_FILENAME /usr/share/webapps/cgit/cgit.cgi;
+ fastcgi_param SCRIPT_FILENAME /var/www/htdocs/cgit/cgit.cgi;
fastcgi_pass unix:/run/fcgiwrap.socket;
fastcgi_param PATH_INFO $uri;
diff --git a/docker-compose.yml b/docker-compose.yml
index b257e99..143c85e 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -14,8 +14,11 @@ services:
- 8080:80
volumes:
- gitolite-git:/var/lib/git
+ - logs_nginx:/var/log/nginx
#command: ["nginx-debug"]
volumes:
gitolite-sshkeys:
gitolite-git:
+ logs_nginx:
+
diff --git a/gitolite/Dockerfile b/gitolite/Dockerfile
index f6749f7..8ac87f6 100644
--- a/gitolite/Dockerfile
+++ b/gitolite/Dockerfile
@@ -17,6 +17,11 @@ VOLUME /etc/ssh/keys
# Volume used to store all Gitolite data (keys, config and repositories), initialized on first run
VOLUME /var/lib/git
+# Permissions are fixed in docker-entrypoint.sh
+RUN mkdir -p /var/lib/git/local/hooks/common
+COPY post-receive /var/lib/git/local/hooks/common/
+RUN chmod +x /var/lib/git/local/hooks/common/post-receive
+
# Entrypoint responsible for SSH host keys generation, and Gitolite data initialization
COPY docker-entrypoint.sh /
RUN chmod +x /docker-entrypoint.sh
@@ -26,5 +31,4 @@ ENTRYPOINT ["/docker-entrypoint.sh"]
EXPOSE 22
# Default command is to run the SSH server
-
CMD ["sshd"]
diff --git a/gitolite/docker-entrypoint.sh b/gitolite/docker-entrypoint.sh
index 94717eb..3d08d34 100644
--- a/gitolite/docker-entrypoint.sh
+++ b/gitolite/docker-entrypoint.sh
@@ -29,6 +29,7 @@ if [ ! -f ~git/.ssh/authorized_keys ]; then
[ -n "$SSH_KEY_NAME" ] || SSH_KEY_NAME=admin
echo "$SSH_KEY" > "/tmp/$SSH_KEY_NAME.pub"
su - git -c "gitolite setup -pk \"/tmp/$SSH_KEY_NAME.pub\""
+ su - git -c "sed -i -Ee 's/# (LOCAL_CODE\\s+=>\\s+\"\\\$ENV\\{HOME\\}\\/local\",.*)/\\1/' ~/.gitolite.rc"
rm "/tmp/$SSH_KEY_NAME.pub"
else
echo "You need to specify SSH_KEY on first run to setup gitolite"
@@ -41,4 +42,9 @@ else
su - git -c "gitolite setup"
fi
+if [ "${1}" != 'sshd' ]; then
+ sed -i -Ee "s/^([^#]*GIT_CONFIG_KEYS\\s*=>\\s*)'[^']*'\\s*,/\\1'cgit.*',/" /var/lib/git/.gitolite.rc
+ #sed -i -Ee "s/^([^#]*GIT_CONFIG_KEYS\\s*=>\\s*)'[^']*'\\s*,/\\1'.*',/" /var/lib/git/.gitolite.rc
+fi
+
exec "$@"
diff --git a/gitolite/post-receive b/gitolite/post-receive
new file mode 100644
index 0000000..3a3e262
--- /dev/null
+++ b/gitolite/post-receive
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+agefile="$(git rev-parse --git-dir)"/info/web/last-modified
+
+mkdir -p "$(dirname "$agefile")" &&
+git for-each-ref \
+ --sort=-authordate --count=1 \
+ --format='%(authordate:iso8601)' \
+ >"$agefile"
diff --git a/init.sh b/init.sh
index 0734004..4acee5c 100644
--- a/init.sh
+++ b/init.sh
@@ -1,5 +1,5 @@
#!/usr/bin/env sh
-set -e
+set -xe
# Only create a new keypair if one does not exist
! [ -f "$(whoami).pub" ] && ssh-keygen -f $(whoami) -t rsa -b 4096
@@ -14,6 +14,8 @@ read ENTRY_DOMAIN
DOMAIN="${ENTRY_DOMAIN:-$DOMAIN}"
echo "DOMAIN=${DOMAIN}" >> .env
+(cd cgit && magick -background transparent favicon.png -define icon:auto-resize=16,24,32,48,64,72,96,128,256 favicon.ico)
+
# Build the image, and run initial setup
docker-compose build gitolite
docker-compose -f docker-compose-setup.yml up -d gitolite