Skip to main content

Install and the first owner

A new installation has no account, no sign-in client and no workspace, and no button in the product creates them. This page goes from an empty machine to the moment the first owner can sign in. Prepare first following Requirements and architecture.

0. Get the release​

How the self-hosted release is distributed has not been decided yet. Today, the self-hosting files are the docker/ folder of the source code at the release you want to install (compose.infra.yaml, compose.app.yaml, deploy.sh, bootstrap.sh, backup.sh, restore.sh, proxy/, systemd/, prod.env.example), and the images are in the project's container registry. Ask whoever gives you the release for two things: the source code of that release and the registry path. When an official way of distribution exists, this page will change.

Keep the whole source tree, do not copy the docker/ folder alone: when images are not pulled, compose builds them from the apps/ folders next to it. The commands below run from that docker/ folder. There are two ways to get the images:

WayWhenCommand in step 3
Pull from the registryA registry holds the release's imagesdeploy --pull <tag>
Build on the machineNo registry; the machine has the full source and can builddeploy <tag> (by default builds from the local source)

<tag> is the image tag of the release: a string set by whoever gives you the release (the project's CI uses the short id of the source revision), not the product's version number. To pull from a private registry, sign in first with docker login <registry>.

1. Fill in the config file​

Put the environment file and the state folder of deploy.sh (the running color, each color's tag, the lock) outside the release folder, so that upgrading into another folder does not lose them. Readable only by the owner:

sudo install -d -m 0750 -o "$USER" /etc/tmspec /var/lib/tmspec/deploy
install -m 0600 prod.env.example /etc/tmspec/env.prod
export TMSPEC_ENV_FILE=/etc/tmspec/env.prod
export TMSPEC_DEPLOY_STATE_DIR=/var/lib/tmspec/deploy

Those two export lines must be present in every later deploy.sh, bootstrap.sh and restore.sh command; put them in the profile of the account you deploy with. By default, if you do not set them, the scripts look for .env.prod and .deploy next to themselves.

Fill in every value in /etc/tmspec/env.prod, generating each password and key once, never reused (openssl rand -hex 32):

GroupVariables
Three DNS namesTMSPEC_WEB_HOST, TMSPEC_API_HOST, TMSPEC_AUTH_HOST
PostgresPOSTGRES_PASSWORD (superuser, used only during preparation)
Database role passwordsTMSPEC_MIGRATOR_PASSWORD, TMSPEC_APP_PASSWORD, TMSPEC_RELAY_PASSWORD, TMSPEC_AUTH_MIGRATOR_PASSWORD, TMSPEC_AUTH_APP_PASSWORD, TMSPEC_AI_MIGRATOR_PASSWORD, TMSPEC_AI_APP_PASSWORD (each at least 16 characters, preferably hex)
The web's cookie keysSESSION_KEYS, in the form kid:key where the key is 32 random bytes in base64. Generate with echo "k1:$(openssl rand -base64 32)"
Registry (only when using --pull)TMSPEC_IMAGE_PREFIX: the project's registry path ending in /, for example registry.example.com/tms/tmspec/. When not set, images are named tmspec- and built on the machine; --pull stops with code 2

A missing required value makes the command stop and name it. Optional variables (ports, network range, retention counts, the AI service, a private CA, a stack name for a second stack on the same machine) are commented in the example file. Set TMSPEC_STACK before the first start if you plan to run two stacks on one machine, because it names the volumes that hold the data.

If your proxy uses a certificate from a private CA, set TMSPEC_CA_BUNDLE in the environment file and export TMSPEC_COMPOSE_FILES="-f $PWD/compose.app.custom-ca.yaml" so every color command also uses that file; browsers and the CLI must trust that CA too.

2. Set up the proxy​

Configure your proxy to send the three names to the three ports of the blue color (web port 3000, API 8080, sign-in 8081 on 127.0.0.1). The proxy/ folder has examples for Caddy, nginx and Traefik, and proxy/README.md lists what the proxy must do. With Caddy, start from proxy/Caddyfile: copy it as your Caddyfile (by default /etc/caddy/Caddyfile), replace the three example host names with yours, and copy proxy/tmspec-upstreams.caddy next to it. The example Caddyfile imports that upstream file, and deploy.sh rewrites that file and reloads Caddy on every deploy (change the path and the reload command with TMSPEC_CADDY_UPSTREAMS and TMSPEC_CADDY_RELOAD). If your Caddy already has a Caddyfile of its own, keep it, add one line import tmspec-upstreams.caddy at the top level (outside every site), then inside each site add import tmspec-web-upstream, import tmspec-api-upstream or import tmspec-auth-upstream accordingly, as in the example.

The proxy cannot be checked yet, because no service runs behind it. The check is at the end of step 3.

3. Start and check​

With Caddy in front, deploy.sh does both the infrastructure and the release and switches the proxy:

./deploy.sh deploy --pull <tag> # pull the release's images from the registry
./deploy.sh deploy <tag> # or: build the images from the local source

The first time, the command starts the infrastructure, creates the signing key, prepares the database and runs the migrations, then starts the empty color, waits until every service is healthy, runs a quick test and points the proxy at it. Do not add --wait to manual compose commands: compose treats a one-off job that has finished as an error.

With nginx or Traefik, deploy.sh does not fit, because it writes Caddy's upstream file and reloads Caddy. Start the infrastructure and the blue color with compose, then switch the proxy by hand following docker/ops/blue-green.md.

Once the stack is up, check from the server. The first command prints the issuer address, the second prints 401, the third prints 200 and shows that the containers reach the issuer through the proxy (point 6 in Requirements and architecture):

curl -s https://auth.tmspec.acme.example/.well-known/openid-configuration | head -c 200
curl -s -o /dev/null -w '%{http_code}\n' https://api.tmspec.acme.example/v1/workspaces
docker compose --env-file "$TMSPEC_ENV_FILE" --env-file colors/blue.env -f compose.app.yaml exec web \
node -e "fetch('https://auth.tmspec.acme.example/.well-known/jwks.json').then(r => console.log(r.status))"

If the third command fails, either the proxy does not listen on an address the containers reach, or the machine's firewall blocks the Docker network, or the private CA is not yet in TMSPEC_CA_BUNDLE.

4. Create the first owner​

Run from a terminal (not from CI or a pipe):

./bootstrap.sh --email owner@acme.example --workspace ACME

The command registers two sign-in clients (one for the web and one for the CLI), creates the account, and creates the workspace ACME with that person as owner. The password is printed exactly once, on the terminal. Copy it right away; it is in no log. If you lose the password before copying it, reset it as in Lost password below. To set the password yourself: --password-file <file>, the first line of the file, 15 to 256 bytes.

FlagMeaning
--emailThe address that person signs in with. Required
--workspace NAMEThe workspace by its exact name. A new name creates the workspace and this person becomes its owner
--workspace-id UUIDPoints at an existing workspace; needed when several workspaces share a name
--slug SLUGThe name in the web address (/w/<slug>/...): 2 to 40 lowercase letters, digits and hyphens. When left out it is taken from the name
--role owner|admin|memberDefault member; the person who creates the workspace is always owner
--name NAMEDisplay name of the new account
--password-file FILEThe new account's password, in place of a generated one

Open the web address, sign in with that email and password, and you are in the workspace.

5. Add people one by one​

The same command adds each person who comes later:

./bootstrap.sh --email bob@acme.example --workspace ACME
./bootstrap.sh --email eve@acme.example --workspace ACME --role admin

Each new account gets a password printed once. A member has no right in any project yet until an admin gives a role in the project; workspace owners and admins are admins in every project.

Safe to run again​

You can run exactly the same command as many times as you like:

  • A client that is already registered is kept. A client that has been disabled is an error, because bootstrap does not undo an operator's decision.
  • An existing account is not touched: the password is not read, generated or printed; the result says "its password is unchanged".
  • The workspace is found by exact name. If several workspaces share a name, the command stops and lists the ids; choose with --workspace-id. Two commands run at the same moment create only one workspace.
  • The last owner cannot be demoted.

If the command stops halfway (a role refused, an ambiguous name), fix it and run exactly that command again: the account is found, the password is kept, the rest is created. Always run through bootstrap.sh, not step by step on your own.

Lost password​

Reset an account's password with the sign-in service's admin command user set-password, run with the admin image already in the stack. The new password (at least 15 bytes) goes through stdin, not in an argument. The command also ends every session and refresh token of that account:

printf '%s\n' "$NEW_PASSWORD" | docker compose --env-file "$TMSPEC_ENV_FILE" --env-file colors/blue.env \
-f compose.app.yaml --profile bootstrap run --rm -T --entrypoint /admin bootstrap-auth \
user set-password -email owner@acme.example

Use colors/green.env if the running color is green (./deploy.sh status).

Next steps​

  • Schedule backups before people start using it. Losing the signing key signs everyone out.
  • Guide users to install the CLI and sign in to https://<API name>.