Run your own GitHub-style Git server with Gitea, PostgreSQL and HTTPS on a €12 VPS: docker compose, Caddy reverse proxy, SSH access for git push, and backups.
Gitea is a lightweight Git service with issues, pull requests and CI hooks - everything you expect, running in a few hundred megabytes. On a €16 VPS it serves a whole team.
apt update && apt install -y docker.io docker-compose-v2 git systemctl enable --now docker
Full walkthrough including Compose basics: Docker guide.
mkdir -p /opt/gitea && cd /opt/gitea
cat > docker-compose.yml <<'EOF'
services:
db:
image: postgres:16-alpine
restart: unless-stopped
environment:
POSTGRES_USER: gitea
POSTGRES_PASSWORD: change-me-db
POSTGRES_DB: gitea
volumes:
- ./db:/var/lib/postgresql/data
gitea:
image: gitea/gitea:1
restart: unless-stopped
depends_on: [db]
environment:
GITEA__database__DB_TYPE: postgres
GITEA__database__HOST: db:5432
GITEA__database__NAME: gitea
GITEA__database__USER: gitea
GITEA__database__PASSWD: change-me-db
volumes:
- ./data:/data
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
ports:
- "127.0.0.1:3000:3000"
- "2222:22"
EOF
docker compose up -dNote the bindings: the web UI listens on localhost only, while SSH for `git push` is on port 2222. Make the port reachable - either open 2222 in the firewall, or later serve Git over HTTPS.
apt install -y caddy
cat > /etc/caddy/Caddyfile <<'EOF'
git.example.com {
reverse_proxy 127.0.0.1:3000
}
EOF
systemctl reload caddyCaddy fetches a certificate automatically. Point the domain's A record at the server first, and finish the setup wizard in the browser - the first account you register becomes the administrator.
git remote add origin ssh://[email protected]:2222/you/project.git git push -u origin main
Add your public key in Gitea's settings once, and every push after that is password-free.
docker compose exec -u git gitea gitea dump -c /data/gitea/conf/app.ini # the dump lands in /opt/gitea/data/gitea, then ship it off-site: restic backup /opt/gitea/data --exclude-caches
The `gitea dump` command bundles the database, repositories and configuration into one archive. Off-site copies: see the restic guide.
The container idles around 150–250 MB, PostgreSQL another 100–200 MB. A 2 GB server is comfortable for a small team; 4 GB if you also run CI runners or many large repositories.
Yes. In Gitea choose New Migration, paste the repository URL, and it copies code, issues and pull requests. Private repositories need a GitHub access token.
It is as safe as your server administration: SSH keys, firewall, updates and off-site dumps cover the realistic risks. For many teams that is more control than trusting a third party with everything.
Gitea plus PostgreSQL fit Core VPS 6 (€16/mo) with room to spare.