Introduction
Forgejo is a self-hosted alternative to Git service providers, allowing developers to manage their repositories with ease. In this guide, weโll walk you through the steps to self-host Forgejo on DigitalOcean, one of the leading VPS providers. Whether youโre managing a homelab or want to experiment with open-source applications, this guide will cover everything you need.
Prerequisites
Before diving into the installation process, ensure the following prerequisites are met:
- Create a DigitalOcean account if you donโt have one. You can sign up here.
- Basic knowledge of command-line interface (CLI).
- A computer running a Unix-like operating system or with SSH access to your VPS.
- A DigitalOcean droplet with at least 1 GB of RAM.
Choosing the Right Droplet
For hosting Forgejo, consider the following DigitalOcean droplet configuration:
| Plan | Monthly Cost | CPU | RAM | Storage |
|---|---|---|---|---|
| Basic Droplet (1GB) | 6 USD | 1 | 1GB | 25GB SSD |
| Standard Droplet (2GB) | 12 USD | 1 | 2GB | 50GB SSD |
| Optimized Droplet | 15 USD | 1 | 2GB | 50GB SSD |
We recommend at least the Basic Droplet for Forgejo to run smoothly. The next tier offers better performance if you expect moderate usage.
Setting Up the VPS
-
Create a Droplet: Log into your DigitalOcean account and create a new droplet based on the desired configuration.
-
Access the VPS: Use
sshto connect to your droplet from a terminal.ssh root@your_droplet_ip
Installing Docker
Forgejo operates within a Docker container. Follow these commands to install Docker:
-
Update the system:
apt update && apt upgrade -y -
Install required packages:
apt install apt-transport-https ca-certificates curl software-properties-common -y -
Add Dockerโs GPG key and repository:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" -
Install Docker:
apt update apt install docker-ce -y -
Verify the installation:
docker --version
Running Forgejo
-
Pull the Forgejo Docker image:
docker pull forgejo/forgejo:latest -
Create a container:
docker run -d --name forgejo -p 3000:3000 -p 222:22 \ -v /srv/forgejo:/data \ forgejo/forgejo:latest -
Access Forgejo: Once the container is running, navigate to
http://your_droplet_ip:3000in a web browser to access the Forgejo interface.
Configuring Forgejo
- Initial Setup: Follow the on-screen instructions to set up your admin account and configure system settings.
- Repository Management: After setting up your account, you can start creating and managing repositories.
Securing Your Installation
To enhance your Forgejo installation security, consider:
-
Setting Up a Firewall: Install UFW if itโs not already installed.
apt install ufw -y ufw allow OpenSSH ufw allow 3000 ufw enable -
Using SSL/TLS: Secure your instance by acquiring an SSL certificate. You can use Letโs Encrypt for a free SSL certificate.
FAQs
Q: What is Forgejo?
A: Forgejo is a self-hosted software development platform, offering Git repository management. It allows users to host their own code, collaborate with team members, and maintain full control over their data. It is an excellent alternative to commercial services like GitHub and GitLab, especially for developers seeking an open-source solution.
Q: How long does it take to set up Forgejo on DigitalOcean?
A: Setting up Forgejo on DigitalOcean typically takes around 30 minutes, depending on your familiarity with command-line operations and Docker. The bulk of the time involves provisioning your VPS, installing Docker, and configuring Forgejo. Once youโve completed the initial setup, you can start using it almost immediately.
Q: Can I use other VPS providers to host Forgejo?
A: Yes, you can host Forgejo on other VPS providers such as Hetzner, Contabo, or Linode. The installation steps are similar, but ensure that you choose a provider that meets Forgejoโs requirements. Additionally, when selecting a VPS provider, consider their pricing and performance characteristics to find the best fit for your needsโcheck our full VPS comparison for a detailed analysis.
Conclusion
Self-hosting Forgejo on DigitalOcean allows developers to maintain full control of their repositories while enjoying the benefits of a robust platform. This guide provides the groundwork for getting Forgejo running on your VPS, setting you up for success in your software development endeavors. Happy coding!