Gitea or Forgejo, Docker or binary
A Git forge adds what you need around your repositories to work as a team: code browsing, issues, pull requests with review, wiki, organisations, per-repository permissions, webhooks and continuous integration. Gitea does all this with a single program. Forgejo is a community fork of Gitea that installs the same way; choose from the start, as the two projects drift apart over time. Two ways to install:
- With Docker Compose: the official
docker.gitea.com/gitea image serves the web interface on port 3000 and Git over SSH on the container's port 22, and keeps everything in its /data volume, which must belong to the user set by USER_UID and USER_GID (1000 by default). Docker installs with the official script: see installing Docker on a VPS.
- As a binary: a single file,
/usr/local/bin/gitea, run by systemd under a git user, with its data in /var/lib/gitea and its configuration in /etc/gitea/app.ini. Gitea requires Git 2.0 or later.
The database. Out of the box, Gitea uses SQLite, a single file in its data folder: that is enough for personal use or a small team. For a larger team, pick PostgreSQL (or MySQL) at installation time; Gitea's documentation pins the PostgreSQL image's major version, because PostgreSQL does not upgrade its data folder on its own. The full method, with Forgejo as the example, is in the guide installing Gitea or Forgejo on a VPS.
Git over SSH, HTTPS and first settings
SSH for Git. With Docker, the VPS's port 22 stays with your own SSH connection: publish the container's port on another one, for example 2222, and tell Gitea about it (SSH_PORT in the [server] section, or GITEA__server__SSH_PORT as an environment variable) so that clone addresses show it. Each user adds their public key in their settings, then:
git clone ssh://git@git.example.com:2222/org/app.git
HTTPS. Publish port 3000 on 127.0.0.1 only and put a reverse proxy in front that holds the Let's Encrypt certificate: Nginx Proxy Manager from a web interface, or Nginx with Certbot. The public address, for example https://git.example.com/, is set in ROOT_URL. Be careful: ports published by Docker bypass UFW rules, and a port published without 127.0.0.1 would be open to the whole Internet.
First settings, to make in the installation wizard:
- create the administrator account with a long password;
- close sign-ups if the forge is private (
DISABLE_REGISTRATION in the [service] section): otherwise, anyone can create an account;
- before anything else, secure the VPS: SSH key, firewall, automatic updates, with securing a Linux VPS and connecting to a VPS over SSH.
Actions, backups and updates
Gitea Actions. Continuous integration has been enabled by default since Gitea 1.21, and is then switched on repository by repository. Workflows are YAML files stored in .gitea/workflows/, modelled on GitHub Actions, which Gitea aims to be compatible with. The forge does not run jobs itself: you install the runner (Gitea Runner) separately, then register it with a token taken from the settings, under Actions then Runners. The runner runs jobs in Docker containers, and Docker works on our VPS. Since it runs your repositories' code, we advise giving it a second VPS of its own, and not opening it to repositories from people you do not know.
Backups are your responsibility. The gitea dump command produces a ZIP archive with an SQL export of the database, the repositories, the data folder and the configuration. The documentation asks you to stop Gitea during the backup, so that the database and the repositories stay consistent. With the binary installation:
sudo systemctl stop gitea
cd /var/lib/gitea && sudo -u git gitea dump -c /etc/gitea/app.ini
sudo systemctl start gitea
Then copy the archive off the VPS: it holds all your code. There is no restore command: you unpack the archive, put each file back in place, import the database, then run gitea admin regenerate hooks. Try it once, before you need it.
Updates: back up, read the release notes, change the image tag (or the binary), then restart. Gitea upgrades its database on start-up: keep the backup until everything has been checked.
When a Gitea VPS is not the right choice
- You do not want to administer anything: on a VPS, the system, Gitea, its updates and its backups are your responsibility, and CloudFive does not offer a managed Git forge.
- Your continuous integration jobs need extended rights: an image to run with
--privileged, a kernel module or Kubernetes have no place on our VPS, which are Linux containers (LXC). A dedicated server gives you the whole machine; the differences are in KVM or LXC VPS.
- Your repositories and LFS files outgrow the disk of our largest VPS: take a dedicated server.
- Your developers are far from France: every clone and every push feels the distance.
To run the forge alongside other containers, see also the Docker VPS page.