
Forgejo (a fork of Gitea) is a community-managed, lightweight code hosting solution focused on speed, simplicity, and community ownership. It provides Git repository hosting, code review, issue tracking, and CI/CD features in a self-hosted environment. Forgejo is efficient, easy to deploy, and runs on a wide range of hardware, from Raspberry Pis to powerful servers.
This article demonstrates how to deploy Forgejo on Ubuntu 24.04 using Docker Compose and secure it with HTTPS via a Traefik reverse proxy.
Before you begin:
forgejo.example.com, to point to your server’s public IP address.Set up the project directory to store persistent Forgejo, MariaDB, and Let's Encrypt files.
Create folders to store Forgejo data, database files, and Let's Encrypt certificates.
data - Forgejo repositories, configs, SSH keys.db - MariaDB database files.letsencrypt - Traefik ACME certificates.Navigate to the root Forgejo directory.
Create a .env file to store environment variables.
Add the following content:
In the above file, replace:
STRONG_APP_PASSWORD with a secure password for the Forgejo DB user.STRONG_MYSQL_ROOT_PASSWORD with a secure password for the MySQL root user.forgejo.example.com with your domain.admin@example.com with your email.Save and close the file.
Deploy Forgejo with Docker Compose, Traefik as reverse proxy, and MariaDB for storage.
Add your user account to the docker user group.
Apply new group membership.
Create and edit a Docker Compose manifest file.
Add the following contents:
Save and close the file.
This Docker Compose file deploys Forgejo behind Traefik, enabling secure HTTPS access using Let’s Encrypt. Each service has a specific purpose:
forgejo service
./data directory..env file.db service (MariaDB)
./db directory for persistent data..env file.traefik service
./letsencrypt directory.Start all services in detached mode.
Check container status.
You should see forgejo, forgejo-db, and traefik listed as "Up".
For more information on managing a Docker Compose stack, see the How To Use Docker Compose article.
Open your browser and visit your Forgejo domain https://forgejo.example.com.
You should see the Initial Configuration page. The database settings are automatically populated from the environment variables.
Scroll down to the Administrator Account Settings section. Expand it.
Fill in the values to create an Administrator user.
Click the Install Forgejo button to finish the installation process. After a few moments, you will be redirected to the dashboard.
By following this article, you successfully deployed Forgejo on Ubuntu 24.04 using Docker Compose and secured it with Traefik. Your Git service now supports all Forgejo's built-in features. For more details, visit the Forgejo documentation.
0 Comments
Be the first to comment and share your perspective with the community.