# Install

> Abstract: Start the three containers with Docker Compose, attach to the installer, and finish setup in the browser. The same image runs with plain Docker or with the included Kubernetes manifests. The command line alone needs only Python.

## What you need

- A host that can run a linux/amd64 image. The build refuses any other architecture, so use an amd64 Linux host or Docker's amd64 emulation.
- Docker with Compose, or a Kubernetes cluster. The included manifests expect [Flux](https://fluxcd.io/).
- A GitHub account that can register an App under the person or organization that owns your repositories, or a GitLab instance where you can create a project or group access token.
- A Cursor, Claude or ChatGPT account to sign in with, or an API key from one of them.

> The setup wizard needs nothing else installed. Everything it uses is in the image, including Assay's forge tools.

## With Docker Compose

Start the containers from a checkout of the repository, then attach to the installer:

```sh
docker compose up -d --build
docker compose attach setup
```

1. Press **Enter** in the attached terminal. It prints a random **setup key** and the local URL.
2. Open `http://127.0.0.1:8765/` and enter the key. The page keeps it in a session cookie.
3. Set the repository, the accounts allowed to request reviews and the review provider in the browser. Follow the provider's sign-in prompts in the same terminal.
4. Leave the checkout paths blank for automatic sync.

The sync and review services wait for the first save, and reload each later save between cycles. [Setup](setup.md) describes what the wizard asks for.

> The setup service publishes its browser port on `127.0.0.1:8765`, and opens the listener only during a wizard session. For a remote Docker host, forward that loopback port to port 8765 on your workstation.

### Leaving setup, and coming back

To return to your shell, type **q** and press **Enter** at the manager menu, or while the browser wizard is waiting for an answer. You can also click **Quit setup** in the browser, or enter **/quit** at a terminal wizard prompt. Quitting closes the installer and discards unfinished edits. The reviewer and sync services keep running with the last saved configuration.

To reopen setup, run `docker compose start setup && docker compose attach setup`. Press **r** there for a fresh provider login.

> The key is regenerated for every wizard session. If you lose it, click **Print key to console** on the page and read the reprinted key from the attached terminal. Treat that terminal as a credential.

The setup service disables Docker log retention while it handles an interactive sign-in. Use `docker compose logs sync reviewer` for the worker logs. The optional `./install.sh` builds or pulls the image and attaches to the same manager; with `REVIEW_IMAGE` set, it pulls instead of building.

### The three services

| Service | Runs | Mounts | Job |
|---|---|---|---|
| `setup` | `manage` | `state`, `repos` (read-only), `provider-login` | The installer, its browser wizard and provider sign-in. Publishes `127.0.0.1:8765`. |
| `sync` | `sync` | `state`, `repos` (writable) | Keeps managed checkouts current with git-sync. |
| `reviewer` | the poller | `state`, `repos` (read-only), `provider-login` | Waits for `/review`, reviews each request, posts the result. |

All three use the same image. Compose starts each with a read-only root filesystem, every Linux capability dropped, no privilege escalation, and a 1 GiB in-memory `/tmp`. The named volumes are `state`, `repos` and `provider-login`.

> `provider-login` holds your provider's sign-in session. The sync service has no mount for it. Protect the volume like a credential.

## With plain Docker

Build the image, then run only the manager from it:

```sh
docker build --platform linux/amd64 -t assay-pr-agent .
docker run -dit --name review-setup --platform linux/amd64 --log-driver none \
  -p 127.0.0.1:8765:8765 -e REVIEW_SETUP_BIND=0.0.0.0 \
  -v review-state:/state -v review-repos:/repos:ro assay-pr-agent manage
docker attach review-setup
```

Use the same state and checkout volumes for the sync and reviewer containers. Compose manages all three services for you.

To run the wizard once in the terminal instead, with a writable state volume and your checkouts mounted where the reviewer will look for them:

```sh
docker run --rm -it --platform linux/amd64 \
  -v review-state:/state -v /path/to/checkouts:/repos:ro assay-pr-agent setup
```

To have a local image report its commit, add `--build-arg REVIEW_BUILD_SHA=$(git rev-parse HEAD)` to the build. Without it the startup banner shows `commit unknown` and the build time.

## Repository sync

Compose runs Kubernetes `git-sync` in a separate container with write access to the checkout volume. For each managed project it refreshes the remote default branch with full history, using the existing reviewer credential, and atomically switches the `current` symlink. The reviewer mounts the volume read-only.

Allow repository contents read access for the GitHub App, or GitLab repository read access for its token. The sync interval defaults to 120 seconds (`REVIEW_SYNC_SECONDS` on the sync service).

Polling uses the forge's diff directly. When a requested review needs a local static scan and its commit is not in the checkout, the reviewer uses git-sync to fetch just that change's ref into a temporary checkout, verifies its SHA, and discards it after scanning. A moved or unavailable ref is reported as incomplete coverage.

In `REVIEW_PROJECTS`, use `"managed": true` in place of a checkout path for a managed clone, or keep your existing absolute `checkout` and bind mount it. With Compose, mount custom checkout paths in both the sync and reviewer services. The sync service leaves operator-managed checkouts alone.

> The checkout volume keeps a full history of every private repository it syncs. Treat it like the credentials, and size it for the histories it will hold.

## On Kubernetes

The `k8s/` directory mirrors `compose.yaml`: one pod with the `setup`, `sync` and `reviewer` containers sharing the `state`, `repos` and `model-auth` volumes. Instead of Compose's attachable manager, the `setup` container runs the browser wizard directly as a sidecar.

Copy the `k8s/` directory into the root of your GitOps repository and point Flux at it. Change `sourceRef.name` in `k8s/flux.yaml` if your GitRepository is not named `flux-system`:

```sh
kubectl apply -f k8s/flux.yaml
kubectl -n pr-agent get pods
```

The wizard exits after each session and the sidecar restarts it, so the setup port is always available. Each session prints a random setup key to the log:

```sh
kubectl -n pr-agent logs deploy/pr-agent -c setup | grep 'Setup key'
kubectl port-forward -n pr-agent svc/pr-agent 8765:8765
```

Open `http://127.0.0.1:8765/` in your browser and enter the key. Keep the local port at `8765`, because the wizard checks the `Host` header. If you choose provider **login**, the browser asks you to continue in the installer terminal when the provider CLI signs in:

```sh
kubectl attach -it -n pr-agent deploy/pr-agent -c setup
```

Finish the sign-in there and detach with **Ctrl-P**, **Ctrl-Q**. To change projects or credentials later, fetch the key from the log again. To switch the provider account, request a fresh sign-in and end the session with **Quit setup**; the next one runs with `--reauth`.

The manifests use the `main` tag. Pin a digest or a `sha-<commit>` tag for reproducible deployments. The three volumes are `ReadWriteOnce`, so the Deployment runs one replica with the `Recreate` strategy. An egress-only `NetworkPolicy` allows DNS and the public internet and blocks private ranges; if your forge or proxy lives in one of them, remove it from the policy's `except` list.

> Every wizard session writes its key to the `setup` container log. The key is valid until that session ends, so restrict access to the pod's logs.

## Without Docker

The command line runs on macOS or Linux with Python 3.12 or later. Install `uv`, Git and the provider CLI, then run these commands in a checkout of the repository:

```sh
uv sync --frozen
.venv/bin/cursor-review --help
```

`cursor-agent status` should show the account you expect to be billed. A headless CI runner can use a scoped `CURSOR_API_KEY`. Run the installed executable from any checkout, or use `--repo` to point it at the project under review.

ShellCheck and actionlint are optional. A missing applicable scanner appears in the report as `could-not-check`.

> Installed this way, the command line reviews local branches. Reading a pull request by number needs Assay's desk tools and their configuration, which the container provides for you.

## Next

- [Setup](setup.md): the wizard, GitHub and GitLab credentials, and private TLS.
- [Review providers](providers.md): sign in with a subscription, or use an API key.
- [Request a review](request.md): post `/review`, or call the command line yourself.

---

Source of this page: https://pr-agent.assay.guide/install
