Ever since August 11. Where Thomas Dohmke (former CEO of GitHub) announced his departure, and GitHub becoming a part of Microsoft’s CoreAI Organization, I had a bad taste in my mouth. Will GitHub still be GitHub if they are fully absorbed into Microsoft?
Well, now is not the time to discuss that. We'll find out in the future, and I hope Microsoft does not enshitificate GitHub like other products they have.

But there's another question:
Do I Trust the CoreAI Organization with my code?
Public repositories yes. There's no difference to me if they scrape the code directly or from my own git server, but private repos? I admit, I don't really trust them not using private code for AI training.

Another reason for me to Self Host is cost and speed. While GitHub is very generous on public and even private repositories, there are limits. Till now, I've never reached them, mainly because I have a very limited number of private repos, but I also do not wanna test these limits.
Also, GitHub runners sometimes take ages to build my stuff, where local builds take a third of the time...

What ever your reasons may be, a Self Hosted git instance can make sense, although if all your work is Public, you probably don't need one.

Which Software?

Now we come to the interesting part.
Which software should we choose?

The two main contestants I had were GitLab and Forgejo.
I know GitLab from school, but never really liked its UI, and it's quite resource heavy as well. According to the official GitLab docs, 8 GB Memory is the least recommended amount for a full installation. There is a way to host a memory constrained version of GitLab. But this requires some further configuration, which I'm frankly too lazy to do, since I don't really need the additional features GitLab provides.
My Forgejo instance on the other hand currently uses 127 MB and another 42 MB for it's Postgres Database, after running for 7 days. I have not found minimal requirements for Forgejo (or Gitea, which Forgejo is based on), but the community has already used it on a Raspberry Pi 3, so they can't be that high ^^'

I think you can already guess which one I choose, Forgejo. It uses significantly less memory, and Forgejo belonging to a Non Profit organization is just another plus for me.

How to install it?

The installation is quite easy. We only need one Database and Forgejo itself. We're not installing a runner in this post.

Forgejo supports SQLite, MySQL and PostgreSQL as database provider. Personally, I choose PostgreSQL.

services:
  server:
    image: codeberg.org/forgejo/forgejo:12
    restart: always
    container_name: forgejo
    environment:
      - FORGEJO__database__DB_TYPE=postgres
      - FORGEJO__database__HOST=db:5432
      - FORGEJO__database__NAME=forgejo
      - FORGEJO__database__USER=forgejo # Change Me !!!
      - FORGEJO__database__PASSWD=forgejo # Change Me !!!
    volumes:
      - ./data/forgejo:/data
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    ports:
      - "3000:3000" # http port
      - "222:22" # Used for SSH, can be disabled
    depends_on:
      - db

  db:
    image: postgres:17
    restart: always
    environment:
      - POSTGRES_USER=forgejo # Change Me !!!
      - POSTGRES_PASSWORD=forgejo # Change Me !!!
      - POSTGRES_DB=forgejo
    volumes:
      - ./data/postgres:/var/lib/postgresql/data
⚠️
Don't forget to change the default database credentials!

After starting the compose, you can navigate to your server on port 3000 where you go through an initial Setup.

Configuration

Unfortunately, only very limited configuration can be done through the UI. Most of it is done in the configuration file. So let's open up our data folder and navigate to the config.

The config is located at data/forgejo/gitea/conf/app.ini
you can use this command to open it in your terminal: nano data/forgejo/gitea/conf/app.ini

I will list some of the most important options here, but Forgejo already has a very detailed docs page which explains all the options in grate detail.
I'd highly suggest you going through the options provided there.

Configuration Cheat Sheet | Forgejo – Beyond coding. We forge.

Config overview

If you open up your config, it'll probably look something like this

The config is divided into different sections like server, database, indexer, sessions, picture or something else.
These sections are very important. If you place an option inside the wrong section, it will not be applied to your instance.

With that in mind, let's go on to the most important settings, at least for me ^^

(maybe) Important options

Default root options.
These are not located in a section and should be at the top of your file.

  • APP_NAME: This is the Name of your instance. For example: My supper cool Forgejo Instance
  • APP_SLOGAN: This is the big title you see on the start page if you're not logged in.

Service section:

  • DISABLE_REGISTRATION: If you want your'r instance for yourself and don't want others to be able to register an account, you can set this option to false, to disable the registration of new accounts.
  • REQUIRE_SIGNIN_VIEW: If you want to enforce a Login, you can activate this option. If true, you need to have a Login to see anything. No login, no access.
  • ALLOW_ONLY_EXTERNAL_REGISTRATION: If you use an IDP (Identity Provider) like Authentik, Tinyauth or Pocket ID, you can enable this to only allow registration from your configured providers.
  • DEFAULT_KEEP_EMAIL_PRIVATE: This option sets the default visibility for email addresses on your accounts. If true, the Email is hidden by default.
  • DEFAULT_USER_VISIBILITY: Can be public, limited or private. Public means anyone, even if not logged in, can see a user. Limited requires a Login, and Private means nobody (except admins) can see an account.
  • DEFAULT_ORG_VISIBILITY: Same options and behavior as DEFAULT_USER_VISIBILITY.

Mail settings

[mailer]
ENABLED = true
SMTP_ADDR = smtp.example.ch
SMTP_PORT = 465
FROM = forgejo@example.ch
USER = SMTP-USER
PASSWD = SMTP-PASSWORD

Well, that's it...

... you've now hopefully got a configured instance of Forgejo which you can use as an alternative to GitHub/Lab, where you are in charge of cost, performance, and most crucially, what happens to your code.

Self Hosted Git - Control what happens to your code

Hosted Git options like GitHub or GitLab are great, but what if you don't trust them, or don't want to pay them for your usage of action minutes? Maybe a self-hosted Git instance is right for you?