Forgejo

Feb 22, 2025

Hosting your own instance of Forgejo or any self hostable Github alternative allows you full control of your code and stops big tech such as Github's owners; Microsoft, from having access to it.

Github is also often scraped for data to train AI, I am not saying that your robots.txt file will stop it from happening on your own instance but its much less likely to happen.

I personally dislike the widespread acceptance of Githubs dominance in the software hosting platforms. There is definitely some hypocrisy in Github being a platform to distribute free and open source code and software when Github its self is a closed source, for profit, proprietary platform.

Why Forgejo

Forgejo is very easy to setup and maintain, I'd go so far as to say its one of the easiest to get running out of all my other self hosted software's.

It is free and open source, using no proprietary code or dependencies and is owned and utilised by Codeberg.

Forgejo has a rich feature list but still manages to be lightweight; using very little system resources.

One of Forgejo's primary goals is implementing forge federation using ForgeFed, This would mean you could have your own Forgejo instance and be able to interact with other instances without needing an account on the other instances. This will be very cool and useful when they manage to implement it.

The Setup

Binary

Docker Compose (My Recommendation)


networks:
  forgejo:
    external: false

services:
  server:
    image: codeberg.org/forgejo/forgejo:10
    container_name: forgejo
    environment:
      - USER_UID=1000
      - USER_GID=1000
      - GITEA_CUSTOM=/data/gitea
      - FORGEJO__database__DB_TYPE=postgres
      - FORGEJO__database__HOST=db:5432
      - FORGEJO__database__NAME=forgejo
      - FORGEJO__database__USER=forgejo
      - FORGEJO__database__PASSWD=forgejo
    restart: always
    networks:
      - forgejo
    volumes:
      - ./forgejo:/data
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    ports:
      - "3000:3000"
      - "222:22"
    depends_on:
      - db

  db:
    image: postgres:14
    restart: always
    environment:
      - POSTGRES_USER=forgejo
      - POSTGRES_PASSWORD=forgejo
      - POSTGRES_DB=forgejo
    networks:
      - forgejo
    volumes:
      - ./postgres:/var/lib/postgresql/data

Pull the images.

docker compose pull

Start the container.

docker compose up -d

To update to a new version re-run the these two commands, Between major versions you will need to alter the docker-compose file, for instance:

- image: codeberg.org/forgejo/forgejo:10
+ image: codeberg.org/forgejo/forgejo:11

It is advised to backup before updates.

Links

https://forgejo.org

https://codeberg.org/forgejo/forgejo