summaryrefslogtreecommitdiff
path: root/git-server
diff options
context:
space:
mode:
authorArseney300 <Arseney300@gmail.com>2026-02-20 04:56:52 +0700
committerArseney300 <Arseney300@gmail.com>2026-02-20 04:56:52 +0700
commitb68790d86a40294ba035b93e40b29f1a071359a1 (patch)
tree8eccd2412be8c287bf5de1d835955b44e8515cab /git-server
parentee7d961c638c3baa0ba12b0451fe5104fecc95a9 (diff)
Add cgit web interface to git-server stack
Adds a lightweight cgit container (Alpine + fcgiwrap + nginx) that auto-discovers bare repos via scan-path and serves them read-only. Accessible at both cgit.swave.lol and swave.lol/cgit through the main nginx reverse proxy. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'git-server')
-rw-r--r--git-server/cgit/Dockerfile18
-rw-r--r--git-server/cgit/cgitrc30
-rw-r--r--git-server/cgit/entrypoint.sh7
-rw-r--r--git-server/cgit/nginx.conf32
-rw-r--r--git-server/server.yaml9
5 files changed, 96 insertions, 0 deletions
diff --git a/git-server/cgit/Dockerfile b/git-server/cgit/Dockerfile
new file mode 100644
index 0000000..9da8b23
--- /dev/null
+++ b/git-server/cgit/Dockerfile
@@ -0,0 +1,18 @@
+FROM alpine:latest
+
+RUN apk add --no-cache \
+ cgit \
+ git \
+ nginx \
+ fcgiwrap \
+ spawn-fcgi \
+ py3-pygments
+
+COPY cgitrc /etc/cgitrc
+COPY nginx.conf /etc/nginx/nginx.conf
+COPY entrypoint.sh /entrypoint.sh
+RUN chmod +x /entrypoint.sh
+
+EXPOSE 80
+
+ENTRYPOINT ["/entrypoint.sh"]
diff --git a/git-server/cgit/cgitrc b/git-server/cgit/cgitrc
new file mode 100644
index 0000000..bf6ab31
--- /dev/null
+++ b/git-server/cgit/cgitrc
@@ -0,0 +1,30 @@
+# cgit config
+
+# Branding
+root-title=swave.lol git
+root-desc=Git repositories hosted on swave.lol
+
+# Repo discovery
+scan-path=/repos
+
+# Features
+enable-index-links=1
+enable-index-owner=0
+enable-log-filecount=1
+enable-log-linecount=1
+enable-commit-graph=1
+snapshots=tar.gz zip
+
+# Syntax highlighting via pygments
+source-filter=/usr/lib/cgit/filters/syntax-highlighting.py
+
+# About tab (use repo description file)
+readme=:README.md
+readme=:README
+
+# Cache
+cache-size=1000
+
+# URL style
+remove-suffix=1
+clone-prefix=git://swave.lol ssh://git@swave.lol/repos
diff --git a/git-server/cgit/entrypoint.sh b/git-server/cgit/entrypoint.sh
new file mode 100644
index 0000000..652ba73
--- /dev/null
+++ b/git-server/cgit/entrypoint.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+# Start fcgiwrap via spawn-fcgi on a unix socket
+spawn-fcgi -s /var/run/fcgiwrap.socket -U nginx -G nginx -- /usr/bin/fcgiwrap
+
+# Start nginx in foreground
+exec nginx
diff --git a/git-server/cgit/nginx.conf b/git-server/cgit/nginx.conf
new file mode 100644
index 0000000..64e35cb
--- /dev/null
+++ b/git-server/cgit/nginx.conf
@@ -0,0 +1,32 @@
+daemon off;
+worker_processes 1;
+error_log /var/log/nginx/error.log warn;
+
+events {
+ worker_connections 128;
+}
+
+http {
+ include /etc/nginx/mime.types;
+ default_type application/octet-stream;
+ sendfile on;
+
+ server {
+ listen 80;
+ server_name _;
+
+ # Serve cgit static assets directly
+ location /cgit-css/ {
+ alias /usr/share/webapps/cgit/;
+ }
+
+ location / {
+ fastcgi_pass unix:/var/run/fcgiwrap.socket;
+ fastcgi_param SCRIPT_FILENAME /usr/share/webapps/cgit/cgit.cgi;
+ fastcgi_param PATH_INFO $uri;
+ fastcgi_param QUERY_STRING $query_string;
+ fastcgi_param HTTP_HOST $server_name;
+ include /etc/nginx/fastcgi_params;
+ }
+ }
+}
diff --git a/git-server/server.yaml b/git-server/server.yaml
index 2e32183..ff20a13 100644
--- a/git-server/server.yaml
+++ b/git-server/server.yaml
@@ -16,6 +16,15 @@ services:
git-network:
ipv4_address: 172.22.0.2
+ cgit:
+ build: ./cgit
+ restart: always
+ container_name: cgit
+ volumes:
+ - /var/git/repos:/repos:ro
+ networks:
+ - git-network
+
networks:
git-network: