Self-host

Run your own.

One release and a Postgres. Pick how you'd like to run it, tell it where it will live, and paste the steps in order.

  1. 1 Add the apt repository and install

    The package bundles its own Erlang runtime. It installs enabled but not started.

    curl -fsSL https://gg.neiam.co/pkg/_keys/deb/neiam \
      | sudo tee /etc/apt/keyrings/neiam.asc > /dev/null
    echo "deb [signed-by=/etc/apt/keyrings/neiam.asc] https://gg.neiam.co/pkg/deb/neiam/gitgud $(lsb_release -cs) main" \
      | sudo tee /etc/apt/sources.list.d/gitgud.list
    sudo apt update && sudo apt install gitgud postgresql
  2. 2 Create the database

    sudo -u postgres psql \
      -c "CREATE USER gitgud PASSWORD 'change-me'" \
      -c "CREATE DATABASE gitgud OWNER gitgud"
  3. 3 Write the configuration

    Run this once: it generates the secrets. Keep a copy of the file somewhere safe — GITGUD_SECRETS_MASTER_KEY encrypts CI secrets and two-factor keys, and without it they're gone.

    sudo tee /etc/gitgud/gitgud.env > /dev/null <<EOF
    PHX_HOST=git.example.com
    DATABASE_URL=ecto://gitgud:change-me@localhost/gitgud
    SECRET_KEY_BASE=$(openssl rand -base64 48 | tr -d '\n')
    GITGUD_RUNNER_JWT_SECRET=$(openssl rand -base64 48 | tr -d '\n')
    GITGUD_SECRETS_MASTER_KEY=$(openssl rand -base64 32)
    GIT_REPOS_PATH=/var/lib/gitgud/repos
    STORAGE_DISK_ROOT=/var/lib/gitgud/storage
    SSH_SERVER_ENABLED=true
    SSH_PORT=2222
    SSH_HOST_KEY_DIR=/var/lib/gitgud/ssh
    REGISTRATION_MODE=open
    EOF
  4. 4 Migrate and start

    sudo -u gitgud sh -c 'set -a; . /etc/gitgud/gitgud.env; exec /opt/gitgud/bin/migrate'
    sudo systemctl start gitgud
  5. 5 Put HTTPS in front

    The forge serves plain HTTP on port 4000 and expects to be reached as https://git.example.com. Any reverse proxy works; Caddy gets the certificate itself.

    caddy reverse-proxy --from git.example.com --to 127.0.0.1:4000
  6. 6 Make yourself the admin

    Register at https://git.example.com/users/register as you@example.com. With no SMTP_RELAY configured, mail is written to the log instead of sent — the sign-in link is in `sudo journalctl -u gitgud`. Then:

    sudo -u gitgud sh -c 'set -a; . /etc/gitgud/gitgud.env; exec /opt/gitgud/bin/git_gud eval "GitGud.Release.promote_admin(\"you@example.com\")"'
  7. 7 Close registration

    Sign-ups were open for you. Back to the default — invite only — and restart:

    sudo sed -i '/^REGISTRATION_MODE=/d' /etc/gitgud/gitgud.env && sudo systemctl restart gitgud

From here

  • Mail: set SMTP_RELAY, SMTP_USERNAME, SMTP_PASSWORD and MAIL_FROM_ADDRESS so sign-in links reach people instead of the log — where anyone who can read it can use them.
  • CI: register a forgejo-runner from a repository's or organization's Actions settings — the page has a snippet per runtime.
  • Behind a proxy that isn't on a private address, set GITGUD_TRUSTED_PROXIES so rate limits see clients rather than the proxy.
  • Everything else — storage backends, federation, package registries, Kubernetes — is in the README.