Self-Hosted
docker compose template, PostgreSQL, Caddy reverse proxy, first admin.
Self-Hosted is the right choice for teams that need on-premises deployment, compliance requirements, or an air-gapped environment. It runs on PostgreSQL and supports any number of users.
Prerequisites
- Linux server (Ubuntu 22.04+ / Debian 12+ recommended)
- Docker 24+ and Docker Compose v2
- A domain name pointed at the server (for HTTPS)
- At least 2 vCPU / 4 GB RAM / 20 GB disk
1. Download the deployment template
git clone https://github.com/niuniu-dev/niuniu.git
cd niuniu/relay/deploy
cp server.yaml.example server.yaml
Edit server.yaml:
auth:
enabled: true
users:
- username: admin
password: your-strong-password-here
role: admin
storage:
driver: postgres
postgres:
dsn: "postgres://niuniu:niuniu_pwd@db:5432/niuniu_server?sslmode=disable"
2. Start the stack
docker compose up -d
On first start the database schema is initialized automatically.
3. Configure Caddy
Caddyfile:
your-domain.com {
reverse_proxy niuniu-server:3000
}
Caddy will provision an HTTPS certificate automatically.
4. Verify
curl -I https://your-domain.com/api/health
# Expected: HTTP/2 200
Open https://your-domain.com in a browser and log in with admin and the password you set.
Backups
Run a weekly pg_dump:
docker compose exec db pg_dump -U niuniu niuniu_server | gzip > backup-$(date +%F).sql.gz
Retain 4–8 weeks of backups.
Upgrading
git pull
docker compose pull
docker compose up -d --force-recreate
Always back up before upgrading.
Next steps
- Core concepts — understand organizations, members, and resource ownership
- Team Edition shares the same codebase as Self-Hosted and behaves identically