trunkjet

Run your own server

On this page

Run your own server

One command starts a complete trunkjet server on your computer: the server with its web app, FoundationDB, an S3 object store (Garage) and a local inbox for sign-in codes. Then you import a public GitHub or GitLab repository and clone it with the tjet command line.

This is for trying trunkjet on one machine (a laptop or a small server only you use). For a team, read Sizing first.

What you need

Linux (x86-64 or arm64)Docker Engine 24 or later with the compose plugin, or Podman 4 with podman-compose (untested)
macOSDocker Desktop 4.30 or later. Intel and Apple Silicon: every image of the stack has a native arm64 variant, so no emulation is needed
WindowsDocker Desktop with the WSL2 backend; run the commands in a WSL2 terminal (Ubuntu)
Everywhere4 GB of free memory, 10 GB of free disk, curl, the port 8640 on 127.0.0.1

No container is privileged, and trunkjet's own containers run as a non-root user.

Start it

curl -fsSL https://trunkjet.io/quickstart.sh | sh

(/install.sh installs the tjet client, not a server.) The script downloads two files into a new folder ./trunkjet (compose.yaml and the control script trunkjet), checks them against SHA256SUMS and runs ./trunkjet up. If you prefer to look first:

mkdir trunkjet && cd trunkjet
curl -fsSLO https://trunkjet.io/quickstart/latest/compose.yaml
curl -fsSLO https://trunkjet.io/quickstart/latest/trunkjet
curl -fsSLO https://trunkjet.io/quickstart/latest/SHA256SUMS
sha256sum -c SHA256SUMS && chmod +x trunkjet
./trunkjet up

The first run generates every secret (the server's keys, the storage key, a one-time setup code) inside a Docker volume, creates the FoundationDB database and the storage bucket, and waits until the server answers. It ends with:

  trunkjet is running:   http://localhost:8640
  Create the admin account (this link works once):

    http://localhost:8640/setup#token=...

  Sign-in codes go to the local inbox: ./trunkjet inbox

Create your account

Open the setup link. Enter your name, a username, your email address and a name for your organization (repositories live in organizations). The page shows the organization's address (Hana's Lab becomes /hanas-lab). This first account is the administrator of that organization. The link works once: after that, nobody can create an account without being invited.

Lost the link before using it? ./trunkjet url prints it again.

Try it with your repository

After the setup you land on the first-run page:

  1. Import a repository. Paste the address of a public repository, for example https://github.com/octocat/Hello-World. trunkjet keeps a live, read-only mirror of it (Mirrors and vendoring); a small repository is there in seconds.

  2. Get the command line client from your own server. On Linux:

    curl -fsSL http://localhost:8640/install.sh | sh
    

    It checks the download against the server's SHA256SUMS and puts tjet in ~/.local/bin. On macOS and Windows install the package for your system (Install the CLI), or use the Linux client inside WSL2.

  3. Sign in and clone.

    tjet --server http://localhost:8640 login --email [email protected]
    tjet clone github.com/octocat/Hello-World hello
    

    The sign-in code arrives in the local inbox: ./trunkjet inbox shows the newest mails. No mail leaves your computer. The first sign-in to a server other than trunkjet.io writes ~/.config/trunkjet/config.toml, so later commands need no --server. On a machine without a keyring service (a server, a container, WSL) the sign-in is kept in a file only you can read, and tjet says so.

Make a change

A mirror only follows its upstream, so nothing can be sent to it. To try the whole loop, make a repository of your own:

tjet repo create demo
tjet clone demo demo && cd demo
echo "hello" > README.md && tjet add README.md
tjet save -m "First file"
tjet send

Open the change in the web app (Repositories, demo, Changes). A change needs one approval before it merges into main, and nobody approves their own change. Invite someone (Organization, Invite; the invitation mail is in ./trunkjet inbox, and tjet org join LINK --email ADDRESS --handle NAME creates their account from it), or, while you try trunkjet alone, tick Allow self-approval in the repository's Settings under Rules for merging. Then approve, merge, and use Roll back this change on the merged change: the roll back is a new change, reviewed and merged the same way.

In the web app you can also add a passkey (Settings, Profile) and sign in with it instead of a code.

Everyday commands

CommandWhat it does
./trunkjet upStart (or start again after a reboot; the containers also restart by themselves)
./trunkjet urlThe address, and the setup link while setup is open
./trunkjet inbox [N]The newest N mails of the local inbox (sign-in codes)
./trunkjet statusThe containers and their health
./trunkjet logs [tjetd|fdb|garage|proxy|inbox]The last log lines
./trunkjet doctorThe containers, the server's readiness and the installation checks (tjet-admin doctor: schema, FoundationDB, storage, clock, queues)
./trunkjet stopStop, keep everything
./trunkjet backup [FILE]A consistent backup of all data and secrets into ./backups/
./trunkjet restore FILEReplace all data with a backup
./trunkjet upgrade [IMAGE]Back up, switch to a new image, migrate
./trunkjet uninstallRemove the containers and all data

Backup and restore

./trunkjet backup stops the server, FoundationDB and Garage for a few seconds, writes one tar.gz of every volume to ./backups/trunkjet-backup-<time>.tar.gz and starts them again. The file holds your repositories and the secrets (the key that encrypts stored email addresses, the storage key): keep it as private as the data, and copy it off the machine.

./trunkjet restore FILE asks for confirmation, replaces every volume with the backup and starts the server. Test a restore once before you rely on it.

Upgrade

./trunkjet upgrade                       # the newest image of your channel
./trunkjet upgrade trunkjet/server:0.2.0 # a specific image

The upgrade takes a backup first (./backups/pre-upgrade-...), stops the server, starts the new image and runs the schema migration (tjet-admin schema migrate). There is no downgrade after a migration: to go back, ./trunkjet restore the pre-upgrade backup with the old image.

Settings

./trunkjet up writes .env next to compose.yaml on the first run. Change it and run ./trunkjet up again.

VariableDefaultMeaning
TRUNKJET_IMAGEtrunkjet.io/trunkjet/server:quickstartThe server image
TRUNKJET_PORT8640Port of the web app and API on this machine
TRUNKJET_BIND127.0.0.1Address the port listens on: only this machine
TRUNKJET_ORIGINhttp://localhost:8640The address people type; sessions and passkeys are bound to it
TJET_SMTP_RELAY, TJET_SMTP_TLS, TJET_MAIL_FROMthe local inboxYour mail relay instead (admin guide, mail)

Other people on your network. Do not just set TRUNKJET_BIND=0.0.0.0: sign-in tokens would cross the network unencrypted. Put a TLS reverse proxy with a real certificate in front of the port, set TRUNKJET_ORIGIN to its https:// address, configure a real mail relay, and keep TRUNKJET_BIND=127.0.0.1. At that point, consider the .deb below.

Sizing

Quickstart (this page)One server, the .debKubernetes, the Helm chart
ForTrying it, one person, a demoA team on one hostSeveral servers, the hosted setup
FoundationDB1 process, no redundancyYour cluster: 3 hosts (double) or 5 (triple)Operator-managed cluster
ContentGarage, 1 node on this diskLocal disk or your S3S3
SurvivesNothing beyond this disk: back up1 or 2 FoundationDB hosts downHosts and zones, per values
Memoryabout 150 MB right after the start (measured); plan 2 GB with real repositoriesfrom 4 GB per hostper values
GuidehereInstall a server on one hostInstall on Kubernetes

Moving from the quickstart to a real installation: export what you need (for Git consumers, tjet-admin export-git) and import it there, or keep mirrors and re-create them; a FoundationDB backup from this single process can also be restored into a new cluster (runbook fdb-restore).

What this is not

  • Not durable beyond one disk. FoundationDB runs with single redundancy and Garage with one node; a broken disk loses everything since the last ./trunkjet backup.
  • Not signed. The images and the files are unsigned; SHA256SUMS protects against a broken download, not against a compromised download site. Pin the checksum file's digest from the release notes with TRUNKJET_SHA256SUMS_SHA256=<digest> before | sh if that matters to you.
  • Apple Silicon is built but not yet tried. The arm64 images run natively on arm64 Linux (tested on a Hetzner CAX server); Docker Desktop on a Mac runs the same linux/arm64 images in its VM, which nobody has tried yet.
  • The local inbox holds every mail of the server. It listens on no port of your machine; ./trunkjet inbox reads it, so whoever may run docker here can read sign-in codes. Fine for a laptop; on a shared machine use a relay.
  • The first address is not verified. The setup trusts the address you type (no mail is needed). Type it carefully: once you configure a real mail relay, sign-in codes for the administrator go to that address.

Building the image yourself

The image is built by Bazel (rules_oci), from this repository:

bazelisk run --config=release //deploy/quickstart:load         # this machine's arch, as trunkjet.io/trunkjet/server:quickstart
bazelisk run --config=release //deploy/quickstart:load_arm64   # linux/arm64 (cross-compiled on an x86-64 host)
bazelisk build --config=release //deploy/quickstart:tarball_arm64   # the same as a tar for `docker load -i` elsewhere
cd deploy/quickstart && ./trunkjet up

Both images (linux/amd64, linux/arm64) are built on an x86-64 Linux host: the arm64 server and client are cross-compiled (--config=linux-arm64, zig as C compiler and linker) and link the aarch64 libfdb_c of the same FoundationDB release. Both carry the Linux client for both architectures under /downloads/. FoundationDB, Garage, Mailpit, Caddy and pause are multi-arch indexes pinned by digest, so compose pulls the machine's own variant.

Publishing it (owner): the image goes to the registry of the server itself (trunkjet.io/v2/, the OCI distribution API of tjetd), as one multi-arch index (one tag, both architectures; docker compose pull picks the right one). Then pin its digest in the released files. tjetd serves compose.yaml, trunkjet and SHA256SUMS from its binary at /quickstart/latest/ and the script at /quickstart.sh, so a release is a new server build.

TJET_PUBLISH_CONFIRM=yes TJET_TOKEN=<token with push rights> make quickstart-publish QUICKSTART_TAG=<version>
# TRUNKJET_REGISTRY overrides the host (default trunkjet.io)
docker buildx imagetools inspect trunkjet.io/trunkjet/server:<version>   # check: linux/amd64 and linux/arm64
# pin the pushed index digest as the default image of deploy/quickstart/compose.yaml and trunkjet
sed -i 's|trunkjet.io/trunkjet/server:quickstart|trunkjet.io/trunkjet/server@sha256:<index digest>|' deploy/quickstart/compose.yaml deploy/quickstart/trunkjet

Pin the index digest, not one architecture's manifest digest: a manifest digest would pin every machine to that architecture.

The image name carries the project's own host on purpose: a short name like trunkjet/server would be pulled from Docker Hub, where nobody controls who owns it.