aboutsummaryrefslogtreecommitdiff
path: root/content/posts/2022-12-31-cgit.md
blob: 52a7941893bdaf449e8b25b93bebed3f1515c00c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
---
.title = "Cgit",
.author = "Martin Ashby",
.date = @date("2022-12-31T23:39:38Z"),
.layout = "single.html",
.custom = {"comments": true},
---

In a [previous post](posts/2022-09-25-back-to-git/) I switched back from fossil to git. I found [gitea](https://gitea.io/) to be a pretty good server. However, it has many features I do not use, and it takes a minimum of 15% of the RAM on my Raspberry Pi home server! I found a simpler setup.

I have switched to plain git server accessed with SSH, which [git-scm](https://git-scm.com/book/en/v2/Git-on-the-Server-Setting-Up-the-Server) documents how to set up. I'd still like a web UI to allow others to see and download my code. [Cgit](https://wiki.archlinux.org/title/Cgit) is a simple web user interface for multiple git repositories. It runs as a CGI application, and I use caddy web server, so thanks to [Luke Hsiao's blog post](https://luke.hsiao.dev/blog/cgit-caddy-gitolite/) and [Andras Schneider's Caddy CGI plugin](https://github.com/aksdb/caddy-cgi) I managed to get it running fairly easily. 

One hitch was adding git LFS support. I use git LFS for some media files on my blog. Gitea includes git LFS support out of the box, but a plain git server does not. I am using the standalone [reference server](https://github.com/git-lfs/lfs-test-server). This has a disclaimer that it's not 'production ready', but since I'm running this behind tailscale I'm reasonably happy it's ok.

A second hitch was figuring out how to redirect from old repo locations to new ones, so I don't have to update every link in my blog. New repo locations simply don't have the `/martin` prefix. This seemed difficult in caddy, until I found [this post](https://caddy.community/t/modify-uri-and-then-redirect/16686/4) and I wound up with the following configuration, which seems to work well:
```
  ...
  handle /martin* {
    route {
      uri strip_prefix /martin
      redir https://{host}{uri}
    }
  }
  ...
```