# Install on a Linux server

> One Linux machine with Docker runs the factory as a container, with an install script that is safe to run again.

This installation puts the factory on one Linux machine. The factory itself runs as a container and starts the sandbox containers on the same Docker daemon. Nothing else is installed on the machine.

## Requirements

- A Linux machine (x86_64 or arm64) with Docker and `docker compose` v2.
- A machine of its own. The factory's container holds the Docker socket, which is equal to root on that host. See [What the machine is trusted with](#what-the-machine-is-trusted-with).
- An Anthropic API key and a GitHub token, as described in the [quickstart](https://codetiller.ai/docs/quickstart.md#before-you-start).
- Disk for repositories, workspaces, dependency volumes and transcripts. `tiller doctor` warns under 10 GB free; the sandbox image alone is a few gigabytes.

## Install

```bash
mkdir tiller && cd tiller
curl -fsSLO https://github.com/TT-Labs/codetiller/releases/latest/download/install.sh
curl -fsSLO https://github.com/TT-Labs/codetiller/releases/latest/download/compose.yaml
sh install.sh
```

The two files are all there is to download: the factory and the sandbox come as published images. Keep the directory; the commands below are run in it.

The script takes its settings from the environment:

| Variable | Default | Meaning |
| --- | --- | --- |
| `TILLER_HOME` | `/var/lib/tiller` | The working directory on the host. Must be an absolute path. |
| `TILLER_PORT` | `4317` | The port on the host. |
| `TILLER_URL` | `http://127.0.0.1:<port>` | The address people open the UI at. |
| `TILLER_BIND` | `127.0.0.1` | The address the port is published on. |
| `TILLER_VERSION` | the release the script came with | The release to install, for example `0.1.0`. |

For example:

```bash
TILLER_HOME=/srv/tiller TILLER_URL=https://tiller.example.com sh install.sh
```

What the script does, in order:

1. Pulls the factory image `ghcr.io/tt-labs/codetiller-factory`.
2. Creates the working directory, owned by uid 1000, with an empty `.env` (mode 600).
3. Writes its settings to `.env` next to itself and starts the factory with `compose.yaml`.
4. Runs `tiller setup` inside the container: pulls the sandbox image `ghcr.io/tt-labs/codetiller-base` of the same release (a few gigabytes) and runs `tiller doctor`.

It does everything through the Docker daemon and installs nothing else on the machine. Running it again is safe: that is also how you [upgrade](#upgrade).

## Add the credentials

The script created `.env` in the working directory (`/var/lib/tiller/.env` by default) with two empty entries. Fill them in:

```bash
ANTHROPIC_API_KEY=...
TILLER_GITHUB_TOKEN=...
```

Then restart the factory so it reads them:

```bash
docker compose restart
```

Edit the file in place so it stays owned by uid 1000 with mode 600.

## Check, onboard, open

```bash
docker compose exec tiller tiller doctor
docker compose exec tiller tiller audit
docker compose exec tiller tiller repo add acme/shop
docker compose logs tiller | grep 'tiller ui'
```

- `tiller doctor` must end with `ready`. Every failed check names its fix.
- `tiller audit` probes the trust boundary from inside the containers. Run it on every new host, because Docker networking differs between hosts. See [Operations](https://codetiller.ai/docs/operations.md#audit).
- `tiller repo add` onboards a repository. See [Add a repository](https://codetiller.ai/docs/repositories.md).
- The last command prints the link to the UI. The link carries the API token, so treat it like a password.

## Access for a team

The port is published on `127.0.0.1` only. To let a team reach the UI:

1. Put a reverse proxy with TLS in front of the port.
2. Pass the public address as `TILLER_URL` when you run `install.sh`. The server answers only to the `Host` values it knows: the loopback names and the one address it was told.
3. Share the link with the token with the people who should have access.

> [!WARNING]
> **One token for everybody**
>
> Until sign-in through GitHub exists, the API token is the only access control, and everybody who has it can do everything: read transcripts and diffs, queue runs, change settings. Keep the UI on a private network or behind your proxy's own authentication.

## The working directory

Everything of an installation lives in `TILLER_HOME`:

| Path | Content |
| --- | --- |
| `.env` | The secrets, mode 600. |
| `tiller.db` | The database (SQLite). |
| `artifacts/` | Transcripts, diffs and manifests of runs. |
| `.cache/` | Repositories, task workspaces, the UI token. |
| `tiller.yaml`, `configs/`, `prompts/` | Optional. A file here replaces the one that ships with the image. |

The directory has the same path inside the factory's container and on the host. That is required: workspaces are mounted into sandbox containers by path, and it is the host's Docker daemon that resolves the path. It belongs to uid 1000, the user of the factory and of every sandbox container, so both can write what the other made.

Back up this directory to back up the installation.

## What the machine is trusted with

- The factory's container holds the Docker socket and therefore controls the host. The factory is trusted; nothing it starts gets the socket.
- The factory container itself runs as uid 1000 without capabilities.
- Git talks to GitHub with the factory's token, sent as a header for `github.com` only. Whatever git credentials the machine has are not used.

## Upgrade

Download the script of the new release over the old one and run it, with the same settings as before:

```bash
curl -fsSLO https://github.com/TT-Labs/codetiller/releases/latest/download/install.sh
curl -fsSLO https://github.com/TT-Labs/codetiller/releases/latest/download/compose.yaml
sh install.sh
```

The script pulls the images of that release and restarts the factory; runs in flight are recorded as failed and can be queued again. The database is migrated when the new factory opens it, after a copy is put next to it. Details and how to go back: [Operations](https://codetiller.ai/docs/operations.md#upgrades-and-the-database).

Repositories onboarded without an image of their own move to the sandbox image of the new release with it. The images of the old release stay on the host until you remove them (`docker image prune -a`).

## Build from source

To run a checkout instead of a release, for example with your own changes:

```bash
git clone https://github.com/TT-Labs/codetiller && cd codetiller
TILLER_BUILD=1 deploy/install.sh
```

This builds the factory image on the host, and `tiller setup` builds the sandbox image `codetiller/base:dev` from `images/base`. The compose commands then need `-f deploy/compose.yaml`.

## Limits

- Sign-in and roles do not exist; access is by the API token.
- Backups are yours to do, apart from the copy made before a database migration.
- Images are published for x86_64 and arm64. Verified on an arm64 Linux host with a regular Docker daemon; rootless Docker and SELinux-enforcing hosts have not been tried.
- One factory per working directory. Nothing stops a second one from being started on the same directory, and it must not be.
