Cgit

In a previous post I switched back from fossil to git. I found gitea 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 documents how to set up. I'd still like a web UI to allow others to see and download my code. 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 and Andras Schneider's Caddy CGI plugin 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. 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 and I wound up with the following configuration, which seems to work well:

  ...
  handle /martin* {
    route {
      uri strip_prefix /martin
      redir https://{host}{uri}
    }
  }
  ...