Forgejo Installation Guide: A Lightweight and More Secure Self-hosted Git Solution than Gitea

Git tutorial - IT technology blog
Git tutorial - IT technology blog

The Problem: When GitHub and GitLab are No Longer the Only Options

Do you want to manage code internally for your team but are wary of GitHub Enterprise’s steep costs? Or have you experienced the pain of installing GitLab on a 2GB RAM VPS only to watch the system freeze under the heavy resource load? I was stuck in this dilemma when our startup needed tighter data security, but our infrastructure budget was anything but generous.

Gitea used to be the star of the self-hosted Git world due to its lightweight nature. However, since the project began moving toward a commercialized model, the community decided to part ways. They created Forgejo—a fully open fork focused on transparency. If you’re used to Gitea, switching to Forgejo feels like putting on a new jacket that offers much more peace of mind.

When I first looked for solutions, I tried throwing Forgejo onto the “weakest” VPS I could find. The performance results were truly shocking. Here are the hard-won insights I gained from deploying this system.

Core Concepts of Forgejo

What is Forgejo?

Forgejo (pronounced /for-‘dʒe-yo/) is a self-hosted Git management platform. It inherits 100% of Gitea’s source code but is driven by the community rather than profit goals. Forgejo was created to ensure that no single organization can control or stifle the development of this free software.

Why Choose Forgejo Over Gitea or GitLab?

  • Extremely Low RAM Usage: You can run Forgejo smoothly on a Raspberry Pi. In fact, at idle, it only consumes about 60-100MB of RAM—10 times less than GitLab.
  • Instant Deployment: All it takes is a single executable or a Docker container to get up and running.
  • Familiar Interface: The layout is very similar to GitHub. The juniors on my team took less than 5 minutes to get comfortable and start pushing code.
  • No Tracking: Forgejo completely removes user tracking code often found in commercial versions and prioritizes fast security patching.

Hands-on: Installing Forgejo with Docker Compose

Using Docker is the fastest and cleanest path. You won’t have to struggle with installing databases or dealing with complex environment configurations on your OS.

1. Prepare the Environment

You need an Ubuntu server with Docker pre-installed. If your server is fresh out of the box, run these commands quickly:

sudo apt update
sudo apt install docker.io docker-compose -y
sudo systemctl enable --now docker

2. Create the Docker Compose Configuration File

Group everything into one directory for easy backups later:

mkdir forgejo-server && cd forgejo-server
nano docker-compose.yml

Paste the code below into the file. I’m using SQLite for simplicity. If you have a larger team (around 50 people or more), switch to PostgreSQL to handle the load better.

version: "3"

networks:
  forgejo:
    external: false

services:
  server:
    image: codeberg.org/forgejo/forgejo:latest
    container_name: forgejo
    restart: always
    networks:
      - forgejo
    volumes:
      - ./data:/data
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    ports:
      - "3000:3000"
      - "2222:22"
    environment:
      - USER_UID=1000
      - USER_GID=1000

Pro tip: I mapped the Git SSH port to 2222. This avoids conflicts with the default port 22 used for remote server access.

3. Launching Forgejo

Activate the server with a single command:

docker-compose up -d

Now, open your browser and type: http://YOUR-SERVER-IP:3000. The Forgejo welcome screen will appear immediately.

4. Quick Configuration via Web Interface

At this stage, just pay attention to a few key points:

  • Database Type: Keep SQLite3 for small projects.
  • Server Domain: Enter your IP or domain (e.g., git.my-lab.com).
  • SSH Port: Enter 2222 (matching the Docker file above).
  • Admin Account: Create one at this step. If you leave it blank, the first person to register on the web will automatically become the admin!

Practical Experience: Implementing Git Flow on Forgejo

With my team of 8, switching to Forgejo helped reduce silly merge conflicts by 60%. The secret lies in the Protected Branches feature.

I strictly lock the main branch, preventing anyone from pushing code directly. All changes must go through a Pull Request (PR). Forgejo’s PR interface is very clean, allowing for direct reviews and comments on individual lines of code. This makes online code reviews much more effective, and juniors improve much faster.

The standard process our team runs:

  1. Create a feature/new-feature branch from develop.
  2. Open a PR targeting develop once the coding is done.
  3. At least one other person reviews and clicks Approve.
  4. Merge into develop for testing.

A major plus is that Forgejo comes with a built-in Issue Tracker and Wiki. You don’t need to install any messy plugins to manage your work smoothly.

Conclusion

Setting up your own Git server isn’t as hard as people say. Forgejo not only saves resources but also gives you absolute control over your intellectual property. For startups or DevOps folks, running a Forgejo instance is an excellent exercise for deep-diving into Docker and source control management.

If you’re looking for the perfect balance between features and speed, Forgejo is the safest bet right now. Don’t hesitate—try installing it now; you’ll wonder why you didn’t know about it sooner!

Share: