Git
Git is a software that helps to keep track of changes made to software that you are developing. Every time you make a significant change (this tends to be hard to delineate in the very early stages of development), you "commit" them, and git stores a snapshot (not exactly true, but it behaves the same) of the codebase at that point in time. You can also have multiple branches of development which can be merged later, which is a helpful tool when working in teams.
Software Forge
A software forge is a platform where developers can collaborate on developing software. Github and Gitlab are two very popular software forges, and most software forges use Git as the underlying version control system, partly because nearly all teams use Git as their version control system of choice.
In addition to having a centralised place to store your code, software forges also include bug tracking and project management features.
Why Forgejo?
If you want to store your code on a server of your choosing, Github is out of the question. You can set up a barebones Git server, but why stop there, in terms of functionality?
GitLab is self-hostable, but is pretty heavy software and may not run on a microcomputer.
Gitea is lightweight and self-hostable, and I nearly chose it but...
Forgejo (pronounced four-jay-yo) is a lightweight, self-hostable, and plans to implement federation. Federation is a feature where people on different Forgejo servers can collaborate with each other, so you don't need to create more accounts or settle for a third-party software forge for collaboration across teams.
Installing Forgejo
Picking A Version
Forgejo gets a new version every quarter, with each version supported until the next one comes out.
The version released every April is a Long Term Support (LTS) version, which is supported until the next LTS version plus one quarter. If you are looking for stability, this is the way to go, so pick the LTS version on the releases page.
Downloading The Chosen Version
The binary installation is simple enough for me to follow, so I have picked it, choosing performance and security over the simplicity of docker.
Download instructions are here, and make sure you get the right version and platform - LTS and Linux arm64 in my case, running on a Raspberry Pi, but amd64 for many larger computers.
Database Preparation
If you intend to use a PostgreSQL database (or other database server) other than the default SQLite, instructions on how to set that up are here.
For PostgreSQL (aka Postgres), you can skip the pg_hba.conf step.
Installation
Installation instructions are here. My recommended modifications to it are below
Create Directories Forgejo Will Use
In the "Create directories Forgejo will use" step, you have to use the provided directories. However, you can create a symbolic link from those directories to a folder on an external storage device.
sudo mkdir <path/to/external/storage>/git/data
sudo chown -h git:git <path/to/external/storage>/git/data && sudo chmod 750 <path/to/external/storage>/git/data
sudo ln -s <path/to/external/storage>/git/data /var/lib/forgejo
sudo chown -h git:git /var/lib/forgejo && sudo chmod 750 /var/lib/forgejo
sudo mkdir <path/to/external/storage>/git/config
sudo chown -h root:git <path/to/external/storage>/git/config && sudo chmod 770 <path/to/external/storage>/git/config
sudo ln -s <path/to/external/storage>/git/config /etc/forgejo
sudo chown -h root:git /etc/forgejo && sudo chmod 770 /etc/forgejo
Install Systemd Service For Forgejo
A systemd service is used to start a service (like the forgejo server) when the computer starts up. When using a database other than SQLite, the tutorial asks you to uncomment the corresponding lines. However, I have not taught you to set up the corresponding postgresql.service, so do not uncomment anything, and do not run the systemctl enable command. The enable command sets the service to start automatically at system boot.
You should run the systemctl start command - this will just start the service, without configuring any auto-start behaviour.
Configuration
Set up the Postgres database.
The HTTP_PORT should contain the internal port number of the service. If you're using a reverse proxy, the Forgejo Base URL should not contain the port number.
The rest should be simple. Enjoy!