# Deployment

> Abstract: Every push to main and every Git tag builds a linux/amd64 image, runs the test suite inside it with networking disabled, and publishes it. Each image carries its commit, its tags and its build time, and prints them first at startup.

## The image

The image is linux/amd64 only. The build stops on any other architecture. It runs as UID 10001. The Compose file and the Kubernetes manifests give it a read-only root filesystem, with `/tmp` as the only writable mount besides the volumes.

| Path | Holds | Written by |
|---|---|---|
| `/state` | Saved setup, request queue, cache, history, advisory databases | All three services |
| `/repos` | Checkouts | `sync` only |
| `/model-auth` | The provider's sign-in session | `setup` and `reviewer` |

The image contains all three provider CLIs, git-sync, Qualgen, Assay's released forge tools, ShellCheck, actionlint, Hadolint, zizmor and OSV-Scanner. You can use it without installing Assay on the host.

> Each bundled tool is pinned by version, or by digest, in the [Dockerfile](https://github.com/medici-finance/assay-pr-agent/blob/main/Dockerfile). Third-party software in the image keeps its own license: the provider CLIs, PR-Agent, Assay's desk tools and Qualgen, and the scanners.

## The build record

The container prints its build record as its first line at startup:

```text
Assay PR Agent build: commit <sha>, tags <a>, <b>, built <time>
```

A local build without that argument prints `commit unknown` and the build time. An image with no record at all says so in the same line. The commit, tags and build time are baked into the image, so a running container always says which build it is.

## Tags

| What was pushed | Tags published |
|---|---|
| `main` | `sha-<commit>`, `main` and `latest` |
| A Git tag | `sha-<commit>` and the tag's own name |
| A Git tag that is reserved, or not valid as an image tag | `sha-<commit>` and `git-ref-<hash>` |
| Any other branch | None |

`latest` is an alias of `main`. Pin a digest or a `sha-<commit>` tag for a reproducible deployment.

GitHub publishes to `ghcr.io/medici-finance/assay-pr-agent`. GitLab publishes to the project's container registry.

## Building it yourself

Use an amd64 Linux runner, or Docker's amd64 emulation:

```sh
docker build --platform linux/amd64 -t assay-pr-agent .
```

Add `--build-arg REVIEW_BUILD_SHA=$(git rev-parse HEAD)` to have a local image report its commit.

## How a published image is tested

A push to `main`, or any Git tag, builds the image, runs the test suite inside it, and publishes only after the tests pass. The tests run with networking disabled, a read-only root filesystem, every capability dropped and no privilege escalation, which is how the container runs in production.

- **GitHub Actions** needs the repository variable `CONTAINER_RUNNER` set to a Docker-capable Linux x64 runner label registered for the repository. The default is `ubuntu-latest`.
- **GitLab CI** uses its available untagged runners. Its Docker-in-Docker job needs a runner configured for privileged DinD, with the TLS client certificate volume shared.

> Neither pipeline uses a provider API key. The tests substitute a local executable for inference and never post externally.

## Environment-only credentials

For Argo CD or Flux, the same container accepts Kubernetes Secret volumes through the `_FILE` variables, or Secret-backed environment variables through `env.valueFrom.secretKeyRef`.

- Mount the files so UID 10001 can read them.
- Choose one source for each credential.
- The reviewer reads its credentials when it starts, so restart or roll the deployment after a rotation.

The [settings reference](settings.md) has every variable, a complete `review.env` and the Pod fragment.

> Assay keeps mode-0600 runtime copies of the credentials it is given. In Docker these live in `/dev/shm`. The keys are excluded from the project settings and the review database. Run one service instance per state volume.

## Upgrading from v0.1.0

Stop the old receiver and start the polling image with the same state volume. It reads the existing project settings, request queue and cache.

You can then remove the forge webhooks, the reverse proxy, the published port, `REVIEW_PUBLIC_URL` and the webhook secrets. The polling container needs only outbound connections.

---

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