# Host on Fly.io

> Let your agent do it: Deploy Hermitbox on Fly.io. Copy the page's `fly.toml` into an empty directory, change `primary_region` only if I ask, and run `fly launch`, keeping the existing configuration. Check that `https://<app-name>.fly.dev/healthz` answers `"status":"ok"`, have me read the `apiKey` the image prints once in the app's logs, set `HERMITBOX_API_URL` and `HERMITBOX_API_KEY` privately for the CLI, and run `hermitbox run -- echo hello`. Never copy the key into a file or this chat. Follow the exact steps in https://docs.hermitbox.dev/v0.2.1/hosting/fly.md.

Deploy Hermitbox on one Fly.io Machine with a persistent state volume. The
[Fly Launch configuration](https://github.com/hermitbox/hermitbox/blob/75b22d18abc93b8be54b6ae2324b97ed713be910/deploy/platforms/fly/fly.toml) names the release image, the
`hermitbox_state` volume, port `8080` and the `/healthz` check.

## Launch the app

1. Copy [fly.toml](https://github.com/hermitbox/hermitbox/blob/75b22d18abc93b8be54b6ae2324b97ed713be910/deploy/platforms/fly/fly.toml) into an empty directory. Change
   `primary_region` from `ams` if you want another region.
2. Run `fly launch` in that directory and keep the existing configuration. Fly Launch assigns
   the app a unique name and attaches `hermitbox_state` to one Machine.
3. Read the `apiKey` the image prints once in **app → Monitoring → Logs** on its first successful
   start.

## Verify the app

```sh
curl -fsS https://<app-name>.fly.dev/healthz
```

It answers with `"status":"ok"`. Point the CLI at the app with its key and run
`hermitbox run -- echo hello`, as [Connect after deployment](https://docs.hermitbox.dev/v0.2.1/hosting.md#connect-after-deployment)
shows.

## Fly.io notes

Keep one Machine. Don't scale to a second Machine, since it would get an independent state volume.

Fly's secrets store accepts values you supply, but the launch configuration generates none, so
the key appears only in the log. `FLY_APP_NAME` gives the HTTPS origin,
`https://<app-name>.fly.dev`.

The configuration asks for a `shared-cpu-2x` Machine with 2 GB of memory, a 10 GB volume, forced
HTTPS and a Machine that stays running.

Fly runs the image in a Machine with a writable root filesystem and its persistent
`/var/lib/hermitbox` mount, and the image user stays root. This configuration adds no Docker
daemon or KVM device. The process policy must pass on the actual guest kernel; see
[Tiers and guarantees](https://docs.hermitbox.dev/v0.2.1/hosting.md#tiers-and-guarantees).

[Configuration](https://fly.io/docs/reference/configuration/),
[volumes](https://fly.io/docs/volumes/overview/), [pricing](https://fly.io/docs/about/pricing/).
