Self-host Cloudzilla

One binary and a PostgreSQL database: no git to install, no message queue, no search service. This guide takes you from a fresh host to a running forge.

Introduction

Everything Cloudzilla needs at runtime is the binary itself and a PostgreSQL database. Git transport (smart HTTP and SSH) is implemented in pure Go via go-git, full-text search runs on Postgres tsvector, and the UI is server-rendered HTML over the wire. That means a deployment is two moving parts you already know how to operate.

In a hurry? Skip to Installation: Docker, a CZ_DATABASE_DSN, and one migrate command get you a forge on port 8080.

What you'll need

  • A Linux host (amd64 or arm64), or Docker on any platform.
  • PostgreSQL 14+, managed or self-run. It's the only runtime dependency. The bundled Compose stack runs PostgreSQL 18.
  • Two open ports: one for HTTP (default 8080) and one for SSH Git access (default 2222).

Installation

Pick whichever fits your stack. Each ships the same server binary plus a small bundled admin CLI (cz-admin) that runs database migrations. Docker is the quickest way to a running instance.

Docker

Pull the alpha image and point it at a database. The schema isn't applied automatically: run cz-admin migrate once (it's bundled in the image), and the database only needs to exist and be reachable.

start the container
$ docker run -d --name cloudzilla \
    -p 8080:8080 -p 2222:2222 \
    -v cloudzilla_data:/data \
    -e CZ_DATABASE_DSN=postgres://cz:secret@your-postgres-host:5432/cloudzilla?sslmode=disable \
    -e CZ_SERVER_BASE_URL=https://git.example.com \
    -e CZ_AUTH_JWT_SECRET=replace-with-a-long-random-string \
    ghcr.io/mkappworks-dev/cloudzilla-app:v0.7.0
migrate once
$ docker exec -it cloudzilla /app/cz-admin migrate

Then open http://localhost:8080; the first visit redirects to /setup.

Docker Compose

If you want Postgres alongside it, this is the whole stack. After it's up, apply migrations once with docker compose exec cloudzilla /app/cz-admin migrate:

docker-compose.yml
services:
  cloudzilla:
    image: ghcr.io/mkappworks-dev/cloudzilla-app:v0.7.0
    ports: ["8080:8080", "2222:2222"]
    volumes: ["cloudzilla_data:/data"]
    environment:
      CZ_DATABASE_DSN: postgres://cz:secret@db:5432/cloudzilla?sslmode=disable
      CZ_SERVER_BASE_URL: https://git.example.com
      CZ_AUTH_JWT_SECRET: replace-with-a-long-random-string
      CZ_AUTH_COOKIE_SECURE: "true"
      CZ_SECURITY_SECRET_KEY: replace-with-at-least-32-random-bytes
    depends_on: [db]
  db:
    image: postgres:18-alpine
    environment:
      POSTGRES_USER: cz
      POSTGRES_PASSWORD: secret
      POSTGRES_DB: cloudzilla
    volumes: ["czdata:/var/lib/postgresql"]
volumes:
  czdata:
  cloudzilla_data:

From source

There's no release artifact for this yet. Build it with make build, which embeds templates and compiled CSS into two static binaries (the server and the admin CLI). No Node.js or runtime to install.

build & run
$ git clone https://github.com/mkappworks-dev/cloudzilla-app.git
$ cd cloudzilla-app
$ make build   # produces dist/cloudzilla (server) and dist/cz-admin (admin)

$ export CZ_DATABASE_DSN=postgres://localhost/cloudzilla?sslmode=disable
$ export CZ_AUTH_JWT_SECRET=replace-with-a-long-random-string
$ ./dist/cz-admin migrate   # apply migrations once
$ ./dist/cloudzilla               # start the server on :8080

First run

Once you've run cz-admin migrate against an empty database, the server waits for you to create the first account.

  1. Run migrations. Apply the schema once with cz-admin migrate (see Installation). It's safe to re-run, since applied migrations are skipped.
  2. Open the instance. Visit http://localhost:8080. The first request redirects to /setup.
  3. Create the superadmin. The first account created at /setup becomes the instance owner, with full admin rights including user and org management.
  4. Add an SSH key. Under Settings → SSH keys, paste your public key so you can push over SSH. See Git access.
  5. Create a repository and push your first commit. That's a working forge.

To invite more users when open registration is off, the superadmin manages invites and the allow_registration setting from Admin → Settings.

Configuration

Cloudzilla reads a config.yaml file, environment variables, or both. Env vars (all prefixed CZ_) override the file, so containerized deployments can skip the file entirely. Dots in a config key map to underscores: auth.jwt_secret → CZ_AUTH_JWT_SECRET. The essentials:

VariableDescriptionDefault
CZ_DATABASE_DSNPostgreSQL connection string. requirednone
CZ_SERVER_BASE_URLPublic URL of the instance. Used in clone URLs, webhooks, and OAuth callbacks.http://localhost:8080
CZ_SERVER_PORTPort the web server binds to.8080
CZ_GIT_SSH_PORTPort the built-in Git SSH server binds to.2222
CZ_GIT_REPOS_ROOTFilesystem path for bare Git repository storage../git-repos
CZ_AUTH_JWT_SECRETSigning secret for JWT session cookies. set in proddev default
CZ_AUTH_COOKIE_SECURESet the Secure flag on cookies. Turn it on when serving over HTTPS.false
CZ_SECURITY_SECRET_KEYEncrypts credentials the server must read back later, such as pull-mirror tokens. At least 32 bytes. set in prodnone
CZ_SERVER_TRUSTED_PROXIESReverse-proxy IPs / CIDRs whose X-Forwarded-For is believed. Needed for per-IP rate limits behind a proxy.none
CZ_STORAGE_BACKENDWhere uploads such as avatars live: local or s3 (set the CZ_STORAGE_S3_* variables for any S3-compatible bucket).local
CZ_RATE_LIMIT_ENABLEDRate-limit pages, API, Git-over-HTTP, archives, and search per user and per IP. Budgets are tunable via CZ_RATE_LIMIT_*.true
CZ_QUOTA_USER_REPOS · CZ_QUOTA_ORG_REPOSLive repositories each user / organization may own. Over the limit, create, fork, import and transfer are refused with 403.0 (unlimited)
CZ_QUOTA_USER_STORAGE_BYTES · CZ_QUOTA_ORG_STORAGE_BYTESDisk, in bytes, each user's / organization's repositories and wikis may use together. Pushes are capped at the space left.0 (unlimited)
CZ_METRICS_LISTEN_ADDRAddress of a separate listener serving Prometheus /metrics. Off when empty.none

Always set CZ_AUTH_JWT_SECRET and CZ_SECURITY_SECRET_KEY to long, fixed random strings in production. The built-in JWT default is a known dev placeholder, and leaving it in place lets anyone forge session tokens.

Email & OAuth (optional)

Both are off until configured. Set CZ_SMTP_HOST (plus CZ_SMTP_PORT, CZ_SMTP_USERNAME, CZ_SMTP_PASSWORD, CZ_SMTP_FROM, CZ_SMTP_TLS) to enable email notifications, email-verified sign-up, and password reset by email. For Google sign-in, set CZ_OAUTH_GOOGLE_CLIENT_ID, CZ_OAUTH_GOOGLE_CLIENT_SECRET, and CZ_OAUTH_GOOGLE_REDIRECT_URL (must match the URI registered in the Google console).

All variables

The table above covers what most installs set. Everything else, from timeouts to rate-limit budgets and S3 storage, is listed here with its default.

Show all 59 variables
VariableDescriptionDefault
CZ_SERVER_PORTHTTP listen port.8080
CZ_SERVER_HOSTHTTP listen address.0.0.0.0
CZ_SERVER_BASE_URLPublic base URL (used for CORS, OAuth, emails, noreply commit addresses).http://localhost:8080
CZ_SERVER_READ_TIMEOUTHTTP read timeout.15s
CZ_SERVER_WRITE_TIMEOUTHTTP write timeout.15s
CZ_SERVER_TRUSTED_PROXIESComma-separated reverse-proxy IPs/CIDRs whose X-Forwarded-For is believed.none
CZ_DATABASE_DSNPostgreSQL connection string.local dev DSN
CZ_DATABASE_MAX_OPEN_CONNSMax open DB connections.10
CZ_DATABASE_MAX_IDLE_CONNSMax idle DB connections.5
CZ_AUTH_JWT_SECRETJWT signing secret: change in production.dev placeholder
CZ_AUTH_JWT_EXPIRYJWT token lifetime.24h
CZ_AUTH_COOKIE_NAMEhttpOnly cookie name.cz_token
CZ_AUTH_COOKIE_SECURESet Secure flag on cookies (enable for HTTPS).false
CZ_GIT_REPOS_ROOTBare git repo storage path../git-repos
CZ_GIT_SSH_PORTSSH server port for git operations.2222
CZ_GIT_SSH_HOST_KEYSSH host key file (auto-generated if missing)../cloudzilla_host_key
CZ_OAUTH_GOOGLE_CLIENT_IDGoogle OAuth client ID (empty = disabled).none
CZ_OAUTH_GOOGLE_CLIENT_SECRETGoogle OAuth client secret.none
CZ_OAUTH_GOOGLE_REDIRECT_URLOAuth redirect URI (must match Google Console).http://localhost:8080/auth/google/callback
CZ_SMTP_HOSTSMTP server host (empty = email disabled). Also enables email-verified signup, email verification and password reset emails.none
CZ_SMTP_PORTSMTP server port.587
CZ_SMTP_USERNAMESMTP username.none
CZ_SMTP_PASSWORDSMTP password.none
CZ_SMTP_FROMFrom address for outgoing email.noreply@localhost
CZ_SMTP_TLSUse TLS for SMTP connection.false
CZ_IMPORT_ALLOW_LOCAL_NETWORKSLet repository imports reach loopback, private and link-local addresses.false
CZ_IMPORT_TIMEOUTTime limit for one repository import.30m
CZ_WEBHOOK_ALLOW_LOCAL_NETWORKSLet webhooks be created for and delivered to loopback, private and link-local addresses.false
CZ_RATE_LIMIT_ENABLEDRate-limit every request that isn't a static asset.true
CZ_RATE_LIMIT_WINDOWLength of the window each budget covers.1h
CZ_RATE_LIMIT_CORE_AUTHENTICATEDPages and /api/* per signed-in bucket.5000
CZ_RATE_LIMIT_CORE_ANONYMOUSPages and /api/* per client IP.1000
CZ_RATE_LIMIT_GIT_AUTHENTICATEDGit-over-HTTP requests per signed-in bucket.1000
CZ_RATE_LIMIT_GIT_ANONYMOUSGit-over-HTTP requests per client IP.200
CZ_RATE_LIMIT_ARCHIVE_AUTHENTICATEDArchive downloads per signed-in bucket.100
CZ_RATE_LIMIT_ARCHIVE_ANONYMOUSArchive downloads per client IP.20
CZ_RATE_LIMIT_SEARCH_AUTHENTICATEDSearches per signed-in bucket.600
CZ_RATE_LIMIT_SEARCH_ANONYMOUSSearches per client IP.60
CZ_QUOTA_USER_REPOSLive repositories each user may own. 0 is unlimited.0
CZ_QUOTA_USER_STORAGE_BYTESDisk, in bytes, each user's repositories and wikis may use together.0
CZ_QUOTA_ORG_REPOSLive repositories each organization may own.0
CZ_QUOTA_ORG_STORAGE_BYTESDisk, in bytes, each organization's repositories and wikis may use together.0
CZ_STORAGE_BACKENDWhere uploaded files such as avatars go: local or s3.local
CZ_STORAGE_LOCAL_ROOTDirectory for the local backend../storage
CZ_STORAGE_S3_ENDPOINTEndpoint URL of an S3-compatible server (R2, B2, Garage, versitygw).AWS
CZ_STORAGE_S3_REGIONBucket region (auto for R2).us-east-1
CZ_STORAGE_S3_BUCKETBucket name; required for s3.none
CZ_STORAGE_S3_ACCESS_KEY_IDStatic key; empty uses the AWS default credential chain.none
CZ_STORAGE_S3_SECRET_ACCESS_KEYStatic secret; set with access_key_id or not at all.none
CZ_STORAGE_S3_PATH_STYLEPath-style URLs, needed by most self-hosted S3 servers.false
CZ_STORAGE_S3_PREFIXKey prefix, so several instances can share a bucket.none
CZ_MIRROR_ENABLEDSync pull mirrors and offer mirror options. When off, existing mirrors stay read-only.true
CZ_MIRROR_ALLOW_LOCAL_NETWORKSLet pull mirrors reach loopback, private and link-local addresses.false
CZ_MIRROR_MIN_INTERVALShortest sync interval a mirror may use.10m
CZ_MIRROR_DEFAULT_INTERVALSync interval for new mirrors (at most 720h).8h
CZ_MIRROR_MAX_CONCURRENTSyncs running at once on each server instance.3
CZ_MIRROR_TIMEOUTTime limit for one sync.30m
CZ_SECURITY_SECRET_KEYKey that encrypts stored credentials, such as mirror tokens. At least 32 bytes.none
CZ_METRICS_LISTEN_ADDRAddress of a second listener that serves only GET /metrics, e.g. 127.0.0.1:9090. Empty turns it off.none

Git access

Cloudzilla speaks both smart HTTP and SSH out of the box, both implemented in pure Go. There is no system git binary involved on the server side.

Over SSH

Add your public key under Settings → SSH keys, then clone using the instance's SSH port (default 2222):

clone over ssh
$ git clone ssh://git@git.example.com:2222/acme/forge.git
# 2222 is the default SSH git port (CZ_GIT_SSH_PORT)

The server's SSH host key is generated on first boot (CZ_GIT_SSH_HOST_KEY, persisted in the data volume). Keep it stable across restarts: replacing it makes clients report REMOTE HOST IDENTIFICATION HAS CHANGED.

Over HTTPS

Use a personal access token as the password. Generate one under Settings → Tokens. Tokens can be scoped read-only or read/write per repository.

clone over https
$ git clone https://git.example.com/acme/forge.git
# username: your handle · password: a personal access token

Protected branches

A branch protection rule can also require a pull request. A matching branch can then change only by merging a PR: direct pushes, force pushes, deletes and browser edits are refused, with no admin bypass. It's off by default, so existing rules behave as before.

Reverse proxy & TLS

For production, terminate TLS at a reverse proxy and forward HTTP traffic to Cloudzilla. SSH stays a direct TCP passthrough on its own port. A minimal Caddy config:

Caddyfile
git.example.com {
    reverse_proxy localhost:8080
}

Set CZ_SERVER_BASE_URL to the public HTTPS URL so generated clone links, webhooks, and OAuth callbacks point at the proxy rather than the internal port. Behind TLS, also set CZ_AUTH_COOKIE_SECURE=true so session cookies carry the Secure flag.

Health & metrics

Two unauthenticated probe endpoints answer on the main HTTP port, ahead of all middleware: no log line, no cookie, no rate limit.

  • /healthz: liveness, 200 ok whenever the process serves HTTP. The Docker image's HEALTHCHECK uses it.
  • /readyz: readiness, 200 when the database, applied migrations, and repository storage all check out, otherwise 503. Use it for load-balancer and Kubernetes readiness probes.

For Prometheus, set CZ_METRICS_LISTEN_ADDR (for example 127.0.0.1:9090) to start a second listener that serves only GET /metrics.

The metrics port has no authentication. Bind it to loopback or a private network only Prometheus can reach. Don't publish it and don't proxy it.

Command-line client

cz is a remote client for a Cloudzilla host: repositories, issues and pull requests from your terminal, plus a raw cz api command. It talks to the HTTP API only, so it runs on any machine that can reach the server, not just the host. It's separate from cz-admin, the operator tool that runs on the server.

Each release attaches a standalone cz archive per platform, with a checksum. The server archive and Docker image don't include it.

cz
$ cz auth login --host https://git.example.com
$ cz repo list
$ cz issue create
$ cz pr list

cz auth login uses the device flow: it prints a one-time code and a URL, you sign in and approve in a browser (2FA works), and cz stores the token it's issued in your OS keychain. For CI, set CZ_HOST and CZ_TOKEN instead, or pipe a token with --with-token.

Single sign-on

A superadmin turns on LDAP or SAML 2.0 at /admin/sso. There are no environment variables for it: the settings are stored in the database, and saving them or switching a provider on asks for the superadmin's password (and 2FA code), because whoever controls the directory can sign in as its users.

ProviderRequiredOptional
LDAPHost, bind DN templatePort (389), base DN, TLS
SAML 2.0Entity ID, IdP sign-in URL, ACS URL, IdP certificatenone

LDAP

Cloudzilla binds as the DN built from the template and the username, for example uid=%s,ou=people,dc=example,dc=com. There is no search step, so the template alone decides who signs in. The directory returns no email, so a new account gets <username>@ldap.local.

SAML

Sign-in starts from Cloudzilla (SP-initiated). Register https://git.example.com/auth/saml/callback as the ACS URL in your identity provider, or give it the metadata at /auth/saml/metadata. Paste the IdP's signing certificate as base64 without the PEM header. Assertions must be signed with SHA-256 or better; encrypted assertions and IdP-initiated sign-in aren't supported yet.

Accounts

The first sign-in creates an account when registration is open. An existing account with the same email is not linked automatically, since only the identity provider vouches for that address. Users with 2FA still enter their code, and suspended accounts can't sign in.

Webhooks

Add webhooks under a repository's Settings → Webhooks. Cloudzilla sends a POST for push, issues and pull_request events, and with a secret set, signs each one with X-Hub-Signature-256 the way GitHub does, so existing receivers verify it unchanged.

A delivery that fails or gets a non-2xx answer is retried after 1 minute, 5 minutes, 30 minutes and 2 hours. Every delivery is kept with its response code, and can be sent again from the same page.

Webhooks can't reach loopback, private or CGNAT addresses (a Tailscale 100.x address, for example). For receivers on your own network, set CZ_WEBHOOK_ALLOW_LOCAL_NETWORKS=true.

Import & mirrors

The Import button on the dashboard (/repos/import) copies a Git repository from another host over HTTP or HTTPS: every branch and tag, with HEAD on the source's default branch. Issues, pull requests, wikis, releases and LFS objects aren't imported. Put credentials in the username and token fields, never in the URL; they're used for that one clone and not stored.

Pull mirrors

Tick Keep this repository in sync to make the copy a read-only pull mirror. It fetches on an interval (10 minutes to a week, 8 hours by default) and follows force pushes and deleted branches, and pushes from the upstream fire the mirror's push webhooks. A mirror's token is stored encrypted, so it needs CZ_SECURITY_SECRET_KEY.

Sources on private networks are refused by default. Set CZ_IMPORT_ALLOW_LOCAL_NETWORKS or CZ_MIRROR_ALLOW_LOCAL_NETWORKS to true to import or mirror from a server on your own network.

Backups

cz-admin backup writes everything an instance needs to one tar archive: the database, every repository, the local storage root, and the SSH host key. It needs pg_dump on the host, at least as new as your server's PostgreSQL (the Docker image bundles it).

Output goes to a temporary file and is renamed on success, so a failed run leaves no partial archive. Use --output - to stream to stdout.

backup
$ cz-admin backup --output /backups/cloudzilla-$(date +%F).tar
$ cz-admin backup --output - | zstd > cloudzilla.tar.zst

The archive holds secrets, including the SSH host key. Store it encrypted.

Restore

cz-admin restore rebuilds an empty instance: it refuses a database that already has tables, a non-empty repository root, an unknown archive version, or an unsafe tar entry, all checked before anything is written. It then restores the database, extracts the repositories, writes the host key, applies any newer migrations, and prints a report of repositories missing a directory or a row. Sign-ins survive only if CZ_AUTH_JWT_SECRET is unchanged.

restore
$ cz-admin restore --input /backups/cloudzilla.tar
$ zstd -dc cloudzilla.tar.zst | cz-admin restore --input -

Upgrading

Upgrades are a binary (or image tag) swap, followed by a migration run. The server doesn't migrate on its own, so run the bundled CLI after pulling the new version.

  1. Back up first with cz-admin backup (see Backups).
  2. Pull the new tag (e.g. bump v0.6.0 → v0.7.0).
  3. Run migrations with the new cz-admin migrate, then restart the container or service.
  4. Watch the logs. The instance reports that it's serving once it's up.

Postgres 17 → 18 (since v0.5.0). The Compose stack now runs postgres:18-alpine, which can't open a volume created by 17. pg_dump -Fc first, remove only the Postgres volume (not down -v), start the new stack, and pg_restore.

cloudzilla-cli is now cz-admin (since v0.7.0). Update scripts, cron jobs, and docker compose exec calls. Audit-log rows written after the rename name the actor cz-admin; older rows keep cloudzilla-cli.

healthz and readyz are now reserved owner names, and migration 082 refuses to run while two accounts have emails that differ only by case. Fix any such accounts, then run cz-admin migrate again.

Cloudzilla is in alpha, so read the changelog before upgrading. Breaking changes are called out there per release.