Gitea is a fantastic GitHub-like service for git remotes and for viewing code and git projects via a web-browser. One can join existing instances (such as Codeberg), or self-host it.
I self-host a Gitea instance. I use a docker-compose.yml
file like the one below.
version: "3"
services:
gitea:
image: gitea/gitea:latest
restart: unless-stopped
environment:
- USER_UID=1000
- USER_GID=1000
networks:
- traefik_net
volumes:
- ./gitea_data:/data
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
ports:
- "22:22"
expose:
- 3000
labels:
- traefik.http.routers.gitea.rule=Host(`domain.com`)
- traefik.http.routers.gitea.tls=true
- traefik.http.routers.gitea.tls.certresolver=myresolver
- traefik.http.services.gitea.loadbalancer.server.port=3000
networks:
traefik_net:
external: true
Change the domain at which you host the instance and setup the DNS/labels as described in the Traefik note.
Then, bring the service up and navigate to it with a web-browser to complete the setup.
Notes
You may notice an additional Traefik label (the loadbalancer.server.port
) not usually required. Since Gitea exposes a web interface (on port 3000) as well as the SSH git interface (on port 22), we need to tell Traefik to route web traffic to the correct port.
I map the SSH git port to port 22 on the host to make git syncing easier.
Backing-up
I recommend uisng the filesystem backup strategy described in the backups note to back-up the gitea_data/
directory.