In my last post, I wrote about self-hosting Notes. Today, we’ll be setting up a simple and easy self-hosted Git Service, Gitea.
This is the 13th post in a series about protecting your privacy by self-hosting while attempting to maintain the conveniences of public cloud services. See the bottom of this post for a list.
Simple and Easy Self-Hosted Git Service
I have several personal side-projects going on that are related to tracking my finances and my health. Because these projects are personal in nature, I thought that it would be great to be able to take advantage of private version control similar to GitHub or GitLab but hosted on my own server inside my home network. I came across Gitea sometime last year and found it to be super easy to set up and get going.
Setting up Gitea in Docker is super easy. We’ll just create a
gitea/docker-compose.yml that contains both Gitea and a PostgreSQL database:
version: "3" services: web: image: gitea/gitea:latest volumes: - /data/gitea/data:/data - /etc/timezone:/etc/timezone:ro - /etc/localtime:/etc/localtime:ro ports: - "3000:3000" - "2222:22" depends_on: - db restart: unless-stopped environment: - USER_UID=1000 - USER_GID=1000 - DB_TYPE=postgres - DB_HOST=db:5432 - DB_NAME=gitea - DB_USER=gitea - DB_PASSWD=finale-ravishing-fool9 - SSH_LISTEN_PORT=22 - SSH_PORT=2222 - SSH_DOMAIN=10.10.10.10 - ROOT_URL=http://10.10.10.10:3000 db: image: postgres:13.1 restart: unless-stopped environment: - POSTGRES_USER=gitea - POSTGRES_PASSWORD=finale-ravishing-fool9 - POSTGRES_DB=gitea volumes: - /data/gitea/postgres:/var/lib/postgresql/data
You’ll notice that ports
3000 (used for HTTP) and
2222 (used for Git via SSH) are made available on the host. You can configure this to fit your needs. Also notice that in this setup,
ROOT_URL are simply configured to point to an IP and specific port. In my case, I am running my server on
In my setup, I have custom nameserver records, a reverse proxy server, and a trusted certificate authority set up to allow connecting to the server via HTTPS. Since this is out of the scope of setting up Gitea, I’ll cover this setup in a future blog post. In the meantime you can just access it via the IP and port combination you specified.
$ docker-compose up -d
Then simply navigate to
http://10.10.10.10:3000 (or whatever IP address or hostname you have configured) and follow the setup from there.
Once you are up and running, you can create new repositories and push your code up just like you do in GitHub or GitLab.
Self-Hosting Your Own Cloud
- Setting up OpenVPN
- SMB File Server with Automated Backups using Rsync/Rclone
- Note-taking with Nextcloud & Syncthing
- Movies and Music using Emby
- Protect Yourself Online with Privacy Tools
- Ad and Tracker Blocking with Pi-Hole
- Building a Personal Private Network with WireGuard
- Monitoring Your Internet Traffic with ntopng
- Building a NAS with ZFS
- Photos and Videos
- Monthly Optical Data Backups
- Note-taking with Notea
- Git Service with Gitea (this post)