Behind the scenes
I always like to see how people organize their corner of the internet. After experimenting for a while, I have finally found a nice setup for my own which I will share in this post. One of the things I tried in my setup is to choose EU-based services as much as possible, even if they're a bit pricier than US alternatives (looking at you Cloudflare).
First of all, this website and all my projects are hosted on a Hetzner VPS for ~6€/month (for a CX23 = 2 vCPU, 4 GB RAM, 40 GB storage). To manage my VPS, I use Ansible playbooks which I just execute from my laptop. That way, I can just control my Unix users, permissions, and general setup declaratively. In a similar way, I control my DNS zones using Terraform via the hcloud provider. This kind of IaC setup might sound overkill for a personal system, but I really like that I can just commit my whole VPS infrastructure and change it at a glance.
I host a few personal apps on this VPS:
- my homepage and blog,
- my private and public git repos (the public ones are browsable at repos.nchagnet.eu),
- a garage instance (lightweight S3 object store),
- a linkding instance to keep track of my bookmarks,
- my own RSS aggregator which I sync with the Android FeedFlow app,
- some demos.
Most of these are just Docker images managed via compose files (provisioned via ansible) and served via a centralized Caddy reverse proxy, which also takes care of HTTPS certificates. My homepage and blog are handled a bit differently. As a static website, it is automatically built on push with my own static site generator enclume and its output served directly by Caddy.
Hosting my own git repos
One aspect I cared a lot about was self-hosting my own git repos instead of always relying on GitHub. For a while, I used soft-serve, a lightweight TUI-first forge with my own frontend slapped on it, but it was recently archived and I couldn't find a mature replacement. I'm keeping a close eye on bugstage but at this moment it's still in very early stages. I considered using Forgejo, Gitea or any like this, but I really wanted something minimalistic, not a Github clone.
Then I remembered that git is purely decentralized; there isn't really a need for a forge. So instead, I just have bare git repositories (i.e. without a worktree) in /srv/git/{public,private}, which I can create and manage directly over SSH with a few custom commands available to the git account. My VPS has a git account running git-shell for SSH access, and HTTP access to public repositories is made possible with git's basic HTTP protocol.
The final thing I wanted to have is some form of hooks or actions. I considered a lot of things, mostly complex, but here again simplicity was my guiding light. The main action I want to run is the one that parses certain links from my linkding instance and publishes them to my linklog. So what I did is create a simple ci Unix account which runs cron jobs. It has no sudo access and no Docker, so its only way to trigger a deploy is to push changes. Daily, it pulls changes into a local clone of the repo, queries new links using an API token for linkding (stored in pass), updates the links database (a simple .json file), and pushes the changes.
Deployment
There are two types of deployments here. The first one is when a new app is added or modified in the compose files. Ansible takes care of the host setup, and then I run a deploy script on the VPS to update the app, which is something I do manually once in a while.
On the other hand, my blog and homepage can change in two ways: when I edit and push new changes, or when the links update cron job runs on the VPS. The simplest solution here was a shared post-receive hook: after a push, the website is automatically rebuilt, copied into a new release directory, and the current symlink is switched to it. The previous release is still there, so rolling back is easy.