---
kind: guide
zz: "0.9.0"
updated: 2026-10-14
state: draft
rules: https://zriz.io/llms.txt
---
# Deploy a zriz runner

A runner calls your resources from inside your network. zz has one inside for `http` and `sql`. Deploy one for `browser` and `cli`, or for a shared env.

## Do you need one? {#need-one}

The runner is open source: [ZrizTech/runner](https://github.com/ZrizTech/runner).

For `http` and `sql`, no. `zz run` starts the runner of zz when no deployed runner is connected. It needs no Docker.

Deploy a runner when the app or the database is not reachable from the computer that runs zz. Also deploy one for a shared env, or for `browser` and `cli` resources.

## How it connects {#connects}

The runner makes outbound connections only: to `https://zriz.io`, and to the resources in its config. Nothing listens. You open no port.

## Deploy one binary {#binary}

This shape is for `http` and `sql`. It needs no Docker.

1. Make the files on a computer with zz: `zz runners init --env <env>`. It writes `config.json`, `runner.env` and `zriz-runner.service`.
2. Copy the files to the server with this line:

```sh
sudo mkdir -p /etc/zriz-runner && sudo install -m 644 config.json /etc/zriz-runner/config.json && sudo install -m 600 runner.env /etc/zriz-runner/runner.env && sudo cp zriz-runner.service /etc/systemd/system/
```
3. On the server, run `sudo sh install.sh` from the runner release. Then run `sudo systemctl enable --now zriz-runner`.

```sh
zz runners init --env staging
```

To upgrade, run `install.sh` again and restart the service: `sudo systemctl restart zriz-runner`. Then `zz runners` shows the runner as connected.

## Deploy with Docker {#docker}

This shape is for `browser` and `cli`. It has two containers, the runner and the worker. The worker holds no secret.

`zz runners init` writes `config.json`, `runner.env` and `compose.yml` when the project has a `browser` or `cli` resource. On a local computer, add `--start` to start them.

```sh
zz runners init --env staging --start
```

On a server, copy the files and run `docker compose up -d`. A `browser` resource takes its URL from the env value `<RESOURCE>_URL`. A `localhost` host becomes `host.docker.internal`.

## The config {#config}

The config holds the names of secrets, not their values. Put each value in `runner.env`.

`config.json`:

```json
{
  "cloud": { "url": "https://zriz.io", "key-env": "ZRIZ_RUNNER_KEY" },
  "resources": {
    "shop": { "type": "http", "base-url": "https://staging.shop.example", "secrets": ["SHOP_API_KEY"] },
    "shop-db": { "type": "sql", "connection": "postgres://app_ro:${SHOP_DB_PASSWORD}@db.example:5432/shop", "read-only": true }
  }
}
```

- The `resources` map is the allowlist. The runner calls no other target.
- `${NAME}` is filled from the environment of the runner. `cloud.url` must be `https`.
- All the projects of an org share its runner. A resource id must be unique in the org.
- A resource file in `.zriz` still needs the key `connection`. zz removes it before a run.

## A read-only Postgres user {#read-only-user}

Use a role that can read and cannot write. Run these statements as the owner of the tables. `<user>` and `<schema>` are yours.

```sql
create role <user> login password '<password>';
grant connect on database <database> to <user>;
grant usage on schema <schema> to <user>;
grant select on all tables in schema <schema> to <user>;
alter default privileges in schema <schema> grant select on tables to <user>;
```

Prove it: an `insert` as this role must fail with `permission denied for table`. Also set `"read-only": true` on the resource.

## Revoke a runner {#revoke}

`zz runners revoke <name>` revokes the key of a runner. The page `/app/runners` shows each runner and each key.

To change a key, revoke the runner and run `zz runners init` again. The key is `ZRIZ_RUNNER_KEY`.

## When it fails {#fix}

- `runner-unavailable`: Only `browser` and `cli` need a deployed runner with Docker. Run `zz runners init --start`.
- `poll refused`: The cloud refused the key. The runner writes one error line and waits, with no restart loop. Revoke the runner and run `zz runners init` again.
- `poll failed`: The runner cannot reach `https://zriz.io`. Permit outbound HTTPS.
- `missing environment variable`: A `${NAME}` of the config has no line in `runner.env`.

[Security](https://zriz.io/docs/security.md#runner-may) gives the rules that the runner obeys.
