about summary refs log tree commit diff
path: root/bundles/git
diff options
context:
space:
mode:
authorRobert Günzler <r@gnzler.io>2026-04-09 11:04:46 +0900
committerRobert Günzler <r@gnzler.io>2026-04-22 14:36:52 +0900
commitf87c066685098da9a67dd410104cbba8c5fdcdbd (patch)
tree5fe9d3c916931959d267123973e3123b1740a5e1 /bundles/git
parentaa913b59b3e5048fec396ee4b50288f740cdfccf (diff)
deploy cgit
Signed-off-by: Robert Günzler <r@gnzler.io>
Diffstat (limited to 'bundles/git')
-rw-r--r--bundles/git/files/Caddyfile58
-rw-r--r--bundles/git/files/cgit.conf1
-rw-r--r--bundles/git/files/cgitrc28
-rw-r--r--bundles/git/files/custom.css12
-rw-r--r--bundles/git/files/traefik.yaml18
-rw-r--r--bundles/git/items.py47
-rw-r--r--bundles/git/metadata.py25
7 files changed, 189 insertions, 0 deletions
diff --git a/bundles/git/files/Caddyfile b/bundles/git/files/Caddyfile
new file mode 100644
index 0000000..99a011e
--- /dev/null
+++ b/bundles/git/files/Caddyfile
@@ -0,0 +1,58 @@
+# vim: noet ts=2 sw=2
+{
+	admin off
+	auto_https off
+	http_port {$CADDY_HTTP_PORT:1414}
+}
+
+http:// {
+	encode zstd gzip
+
+	handle /healthz {
+		respond OK 200
+	}
+
+	handle /custom.css {
+		root * /var/www/cgit/
+		file_server
+	}
+
+	@static_paths {
+		path /robots.txt
+		path /cgit.css
+		path /cgit.png
+	}
+	handle @static_paths {
+		root * /usr/share/webapps/cgit/
+		file_server
+	}
+
+	handle {
+		reverse_proxy unix//run/fcgiwrap/fcgiwrap.sock {
+			transport fastcgi {
+				env DOCUMENT_ROOT /usr/share/webapps/cgit/
+				env SCRIPT_FILENAME /usr/share/webapps/cgit/cgit.cgi
+			}
+		}
+	}
+
+	log {
+		format filter {
+			wrap console {
+				time_format wall_milli
+				level_format color
+			}
+			fields {
+				common_log delete
+				request>headers>Accept-Encoding delete
+				request>headers>Accept-Language delete
+				request>headers>Connection delete
+				request>headers>Authorization delete
+				request>remote_addr ip_mask {
+					ipv4 24
+					ipv6 32
+				}
+			}
+		}
+	}
+}
diff --git a/bundles/git/files/cgit.conf b/bundles/git/files/cgit.conf
new file mode 100644
index 0000000..a7c0fbe
--- /dev/null
+++ b/bundles/git/files/cgit.conf
@@ -0,0 +1 @@
+www_port=${node.metadata.get("www/cgit/port")}
diff --git a/bundles/git/files/cgitrc b/bundles/git/files/cgitrc
new file mode 100644
index 0000000..36eb882
--- /dev/null
+++ b/bundles/git/files/cgitrc
@@ -0,0 +1,28 @@
+enable-blame=1
+enable-commit-graph=1
+enable-follow-links=1
+enable-log-filecount=1
+enable-log-linecount=1
+
+css=/custom.css
+logo=https://gzr.im/media/interface/logo.svg
+
+mimetype.html=text/html
+mimetype.js=text/javascript
+mimetype.css=text/css
+mimetype.py=text/x-script.python
+mimetype.png=image/png
+mimetype.gif=image/gif
+mimetype.jpg=image/jpeg
+mimetype.jpeg=image/jpeg
+
+root-title=robert's git repos
+root-desc=nothing to see here
+
+about-filter=/usr/lib/cgit/filters/about-formatting.sh
+source-filter=/usr/lib/cgit/filters/syntax-highlighting.py
+
+readme=:README.md
+readme=:README
+
+scan-path=/var/lib/git/
diff --git a/bundles/git/files/custom.css b/bundles/git/files/custom.css
new file mode 100644
index 0000000..cdb5e61
--- /dev/null
+++ b/bundles/git/files/custom.css
@@ -0,0 +1,12 @@
+@import url("cgit.css");
+
+div#cgit {
+	max-width: 117ch;
+	margin: auto;
+	font-family: monospace;
+	tab-size: 4;
+}
+
+div#cgit table#header td.logo img {
+	max-width: 96px;
+}
diff --git a/bundles/git/files/traefik.yaml b/bundles/git/files/traefik.yaml
new file mode 100644
index 0000000..d3333f4
--- /dev/null
+++ b/bundles/git/files/traefik.yaml
@@ -0,0 +1,18 @@
+http:
+  services:
+    cgit:
+      loadBalancer:
+        servers:
+          - url: http://${node.metadata.get("container_gateway", "10.89.0.1")}:${node.metadata.get("www/cgit/port")}
+
+  routers:
+    cgit:
+      rule: Host(`git.demo.gzr.im`)
+      entryPoints:
+        - http
+        - https
+      service: cgit
+      middlewares:
+        - tls-redirect@file
+      tls:
+        certResolver: le
diff --git a/bundles/git/items.py b/bundles/git/items.py
new file mode 100644
index 0000000..22948ae
--- /dev/null
+++ b/bundles/git/items.py
@@ -0,0 +1,47 @@
+if node.os != "alpine":
+    raise BundleError(f"{node.name}: OS {node.os} is not supported.")
+
+svc_openrc = {
+    "fcgiwrap": {
+        "enabled": True,
+        "running": True,
+        "runlevel": "default",
+        "needs": [
+            "pkg_apk:fcgiwrap",
+        ],
+    },
+}
+
+directories = {
+    # this is where we store repos
+    "/var/lib/git": {
+        "mode": "0775",
+        "group": "wheel",
+        "owner": "robert",
+    },
+    # this is the webroot
+    "/var/www/cgit": {
+        "mode": "0775",
+        "group": "www-data",
+        "owner": "webdeploy",
+    },
+}
+
+files = {
+    "/var/www/cgit/Caddyfile": {},
+    "/var/www/cgit/custom.css": {},
+    "/etc/cgitrc": {},
+
+    "/etc/s6-rc/cgit.conf": {
+        "content_type": "mako",
+    },
+
+    # TODO: run behind go-away and expose?
+    "/etc/traefik/cgit.yaml": {
+        "content_type": "mako",
+        "source": "traefik.yaml",
+        "needs": {
+            "bundle:traefik",
+        },
+    },
+}
diff --git a/bundles/git/metadata.py b/bundles/git/metadata.py
new file mode 100644
index 0000000..bcc825b
--- /dev/null
+++ b/bundles/git/metadata.py
@@ -0,0 +1,25 @@
+defaults = {
+    "apk": {
+        "packages": {
+            "git": {},
+            "cgit-pink": {},
+            "fcgiwrap": {},
+            "fcgiwrap-openrc": {},
+            # filter deps
+            "py3-markdown": {},
+            "py3-pygments": {},
+        },
+    },
+    "www": {
+        "cgit": {},
+    },
+    # "backup": {
+    #     "/var/lib/git": {},
+    # },
+    # "metrics": {
+    #     "git": {},
+    # },
+    # "go": {
+    #     "git": "https://git.gzr.im",
+    # },
+}