Skip to content

Forgejo

Community-Driven Git Platform

Forgejo is a self-hosted lightweight software forge written in Go. It's a community-driven fork of Gitea that provides Git repository hosting, issue tracking, code review, and CI/CD capabilities with a focus on decentralization and user freedom.

Why Choose Forgejo?

  • Community-driven - democratic governance without vendor lock-in
  • Full Git platform - repositories, issues, pull requests, CI/CD
  • GitHub Actions compatible - familiar workflows and automation
  • Self-hosted - complete data ownership on your infrastructure

Install

Infrastructure as Code

This Forgejo instance is deployed using OpenTofu with custom Incus images. The infrastructure configuration manages container provisioning and persistent storage volumes.

Custom Forgejo Image

The Forgejo Incus image is built and maintained at forgejo.benoit.jp.net/Benoit/Laminar.

Infrastructure Configuration

The OpenTofu configuration provisions:

  • Incus instance running custom Forgejo image
  • Two persistent storage volumes:
    • /var/lib/forgejo - Git repositories, database, and application data
    • /var/backups/forgejo - Backup storage
OpenTofu Configuration
resource "incus_storage_volume" "forgejo_var_lib_forgejo" {
  name = "forgejo_var_lib_forgejo"
  pool = incus_storage_pool.default.name
}

resource "incus_storage_volume" "forgejo_var_backups_forgejo" {
  name = "forgejo_var_backups_forgejo"
  pool = incus_storage_pool.default.name
}

resource "incus_instance" "forgejo" {
  name  = "forgejo"
  image = "laminar.incus:forgejo-12.0.2-1benoitjpnet"

  device {
    name = "var_lib_forgejo"
    type = "disk"
    properties = {
      path   = "/var/lib/forgejo"
      source = incus_storage_volume.forgejo_var_lib_forgejo.name
      pool   = incus_storage_pool.default.name
    }
  }

  device {
    name = "var_backups_forgejo"
    type = "disk"
    properties = {
      path   = "/var/backups/forgejo"
      source = incus_storage_volume.forgejo_var_backups_forgejo.name
      pool   = incus_storage_pool.default.name
    }
  }
}

Deploy Infrastructure

Apply OpenTofu configuration
tofu apply

After provisioning, configure Forgejo by editing /etc/forgejo/app.ini with your database settings, domain, and preferences. Follow the official Forgejo documentation for initial setup.

Upgrade

Incus Image Upgrade

When upgrading to a newer Incus image version, follow these steps to migrate your data.

Backup current instance configuration before upgrading:

Enter Incus container
incus shell forgejo

Copy configuration file

cp /etc/forgejo/app.ini /var/backups/forgejo/

Deploy to new Incus image and restore configuration:

Update OpenTofu configuration

Edit your OpenTofu configuration file to update the image version:

resource "incus_instance" "forgejo" {
  name  = "forgejo"
  image = "laminar.incus:forgejo-NEW-VERSION"  # Update this line
  # ...
}

Apply infrastructure changes

Provision new Incus container
tofu apply
Enter Incus container
incus shell forgejo

Restore configuration file

cp /var/backups/forgejo/app.ini /etc/forgejo/

Restart Forgejo service

systemctl restart forgejo

Upgrade Complete

Your Forgejo instance is now running on the new Incus image with all repositories and data intact!


Related Documentation: