Skip to content

Migrate to forgejo

In this blog post I explain why I left GitLab and how I moved my repositories and my CI to Forgejo and Forgejo Actions.

Migrate_to_Forgejo_1

Motivation

The reason why I left gitlab.com is simple: If GitLab deactivates my account, would I still have backups of my repositories? Probably not.

Parallel to gitlab.com, I also self-hosted my own GitLab instance for over a year. A lot of features GitLab provides are perfect for me: Environments, Subgroups within a Group, Terraform State, and the very feature-rich CI/CD stuff.

Also, my own GitLab instance was still a very big platform. GitLab is a huge piece of software: it needs a lot of resources (and nowadays RAM is expensive :/), and takes a long time to start.

I needed something smaller but equally feature-rich: simple git hosting, pull requests and a solid CI. The CI especially is a huge deal for me, because almost everything I do has at least one CI pipeline. Everything from container images to my Ansible deployments is built and tested there.

Quick Overview of My Infrastructure

The new setup is used in two different ways: for my overall cloud infrastructure and for my homelab.

Cloud Infrastructure

My Cloud Infrastructure looks like this. To keep it simple, I only show 4 servers here. In reality I have many more, but they all follow the same pattern:

flowchart TD
    p5["srv-prod-01<br/>k3s node"]
    p2["srv-prod-02<br/>normal"]
    p3["srv-prod-03<br/>normal"]
    p4["srv-prod-04<br/>k3s node"]
    p6["...<br/>normal"]

    p5 --> p2
    p5 --> p3
    p5 --> p4
    p5 --> p6

The srv-prod-01 is the main server, which runs the Ansible deployments for my infrastructure. I also run a Wazuh instance on it to monitor and secure my cloud infrastructure. All the applications and services I run on the personal VPSes are like my "production environment". Some of the VPSes are publicly accessible, for example to share files with friends via Nextcloud. The main server, on the other hand, is only accessible from my own VPN or from a few selected networks.

HomeLab

In my homelab I experiment with stuff, break things, and fix them afterwards. It consists of:

  • A cluster of 5 Raspberry Pis
  • 1 Raspberry Pi 5
  • 2 old Laptops

Moving away from GitLab

As mentioned in the intro, I decided to go with Forgejo as a replacement for GitLab. Forgejo is a fork of Gitea and is written in Go.

Forgejo provides all the features that I really need:

  • git hosting over HTTPS and SSH
  • Pull Requests and code review
  • Issues and a wiki
  • a package registry
  • Forgejo Actions as CI (more on that below)

Unfortunately, not all features that I regularly used on GitLab are supported in Forgejo. I now have to live without the following:

  • Subgroups: Forgejo only knows flat organizations (Issue: #12873)
  • Environments
  • Terraform State (Issue #3606)

The big advantage of Forgejo is that it doesn't need a lot of resources to operate, which means I can run multiple in parallel. For example, one only for me, privately, and one publicly accessible where I can share some of the stuff I build.

Migrating the repositories

The migration of around 400 repositories worked better than expected, with Merge Requests, Issues etc. I used the migration API of Forgejo, so I did not have to move anything by hand.

The bottleneck during the migration was gitlab.com, not my Forgejo instance. Most of the time Forgejo was just waiting for GitLab to deliver the data.

Forgejo Actions

The Continuous Integration is the one part where I could not compromise on. Forgejo Actions is close to GitHub Actions: Workflows are written in YAML format and run on runners that I host myself.

Previously, on GitLab, I invested a lot of time in improving my CI. I used reusable CI pipelines, GitLab components that I wrote myself, and normal per-project pipelines. Forgejo Actions also lets you write reusable workflows, but a .gitlab-ci.yml can't be copied easily to Forgejo Actions.

I'm still figuring out, how I optimise the Actions workflows, to get back the level of reusable CI/CD that I had on GitLab.

Resource Consumption

Migrate_to_Forgejo_2

My Forgejo instance now holds 396 repositories, 36 organizations and more than 55,000 issues and still it is very light on resources: in normal operation the process memory sits at around 250-400 MiB and the CPU stays below 10%.

For comparison: GitLab took 6 GB of RAM on idle, without any traffic.

Comments

Reply on this Mastodon post to join the discussion.