Run Your Own Git Server: Self-Hosting Gitea with InfraPilot
InfraPilot Team
March 20, 2026
Why Self-Host Your Git Server?
GitHub, GitLab, and Bitbucket are all excellent — but they charge per seat for private repos or advanced features, and your code lives on their infrastructure. Self-hosting Gitea gives you unlimited private repos, CI/CD hooks, issue tracking, and a GitHub-like interface, all on your own server for the cost of a VPS.
Gitea is built in Go — the server binary uses under 50 MB of RAM at idle. It runs comfortably on a $6/mo VPS alongside other services.
Prerequisites
- VPS with Docker installed
- InfraPilot installed:
curl -fsSL https://infrapilot.org/install.sh | bash - A subdomain for Gitea (e.g.
git.yourdomain.com)
Step 1 — Create the Compose Stack
mkdir -p ~/apps/gitea && cd ~/apps/gitea
services:
gitea:
image: gitea/gitea:1-rootless
restart: unless-stopped
environment:
GITEA__database__DB_TYPE: postgres
GITEA__database__HOST: db:5432
GITEA__database__NAME: gitea
GITEA__database__USER: gitea
GITEA__database__PASSWD: ${DB_PASSWORD}
GITEA__server__DOMAIN: git.yourdomain.com
GITEA__server__ROOT_URL: https://git.yourdomain.com
GITEA__server__HTTP_PORT: 3000
GITEA__server__SSH_PORT: 2222
GITEA__server__SSH_LISTEN_PORT: 2222
ports:
- "3010:3000"
- "2222:2222"
volumes:
- gitea_data:/var/lib/gitea
- gitea_config:/etc/gitea
depends_on:
- db
db:
image: postgres:16-alpine
restart: unless-stopped
environment:
POSTGRES_DB: gitea
POSTGRES_USER: gitea
POSTGRES_PASSWORD: ${DB_PASSWORD}
volumes:
- db_data:/var/lib/postgresql/data
volumes:
gitea_data:
gitea_config:
db_data:
Create .env:
DB_PASSWORD=strong-gitea-db-password
docker compose up -d
Step 2 — Configure the Reverse Proxy in InfraPilot
- InfraPilot → Traffic → Proxy Hosts → Add Proxy Host
- Domain:
git.yourdomain.com - Forward host:
gitea, port:3000 - Enable Let's Encrypt SSL, force HTTPS
- Enable WebSocket support (needed for the Gitea UI)
Step 3 — Initial Gitea Setup
Visit https://git.yourdomain.com — you'll see the Gitea installation wizard. Most settings are pre-filled from the environment variables. Set your admin account credentials and click Install Gitea.
SSH Push/Pull
For SSH access to repositories, Gitea listens on port 2222. Your server firewall must allow this port. Clone repos with:
git clone ssh://git@git.yourdomain.com:2222/user/repo.git
Or add an SSH config entry:
Host git.yourdomain.com
Port 2222
User git
Then clone normally: git clone git@git.yourdomain.com:user/repo.git
Monitoring Gitea with InfraPilot
Gitea is extremely lightweight — you'll typically see the container using under 100 MB RAM. InfraPilot's unified logs let you watch for failed login attempts or push errors without SSHing into the server. Set up an alert to notify you if the Gitea container restarts unexpectedly.
Related posts
The Best Self-Hosted Docker Dashboards in 2026 (Honestly Compared)
Portainer, Dockge, Yacht, Lazydocker, InfraPilot — there are more Docker management UIs than ever. Here's an honest breakdown of which one fits which use case, from CLI-lovers to teams that want a full web dashboard.
Nginx Proxy Manager vs InfraPilot: Is There a Better Alternative?
Nginx Proxy Manager is the most popular Docker reverse proxy GUI — but it only manages proxies and SSL. If you're already running Docker containers, there's a case for combining your proxy management with your container dashboard.
Portainer vs InfraPilot: The Honest Docker Management Comparison (2026)
Portainer is great — but it doesn't manage Nginx, SSL, or give you traffic analytics. Here's an honest comparison of when to use Portainer, when to use InfraPilot, and what actually matters for single-server Docker setups.