# 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.3.2/hosting/fly.md.

Get Hermitbox on one Fly.io Machine with HTTPS and a persistent state volume, from one file and
`fly launch`. The [Fly Launch configuration](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/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/cdd62e6c07e07c2b649b726729b4d8da6b25a737/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.3.2/hosting.md#connect-after-deployment)
shows.

## Fly.io notes

Keep one Machine. A second Machine would get its own, 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.3.2/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/).
