# Host on Railway

> Let your agent do it: Deploy Hermitbox on Railway from its published template, https://railway.com/deploy/hermitbox, as one service with one state volume. If you can't act in my Railway account, walk me through each step in its dashboard. Then check that `/healthz` answers `"status":"ok"`, have me take the key from the service's variables or its first log, 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.4/hosting/railway.md.

Deploy Hermitbox on Railway as one service with one state volume.

[![Deploy on Railway](https://railway.com/button.svg)](https://railway.com/deploy/hermitbox)

The published template sets every value in the
[Railway fields](https://github.com/hermitbox/hermitbox/blob/c61777fdb140d97cded5ef039bce3a7e7c7a2a18/deploy/platforms/railway/template.md) and generates the first API key.
After it deploys, give the service 2 GiB of memory to start, then
[verify the service](#verify-the-service).

## Create the service yourself

Without the template:

1. In Railway's Template Composer, or in a new project, add one service from the image the
   [Railway fields](https://github.com/hermitbox/hermitbox/blob/c61777fdb140d97cded5ef039bce3a7e7c7a2a18/deploy/platforms/railway/template.md) name, with one replica.
2. Add a volume at `/var/lib/hermitbox`, generate a domain with target port `8080`, and set the
   health check to `/healthz`.
3. Set the variables from the same file; outside Template Composer, leave out
   `HERMITBOX_BOOTSTRAP_API_KEY`, whose value is a template function. Start with 2 GiB of memory
   for embedded Postgres, the store and sandboxes, then deploy.

## Verify the service

```sh
curl -fsS https://<service-address>/healthz
```

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

## Railway notes

In a template, `HERMITBOX_BOOTSTRAP_API_KEY=${{secret(64)}}` generates the key. Find it in
**service → Variables**. On a service without that variable, read the `apiKey` the first
successful start prints once in the service log.

`RAILWAY_PUBLIC_DOMAIN` gives the HTTPS origin, and the fields also set `HERMITBOX_PUBLIC_URL`
from it.

Keep one instance, the image's root user, its writable container filesystem and its one state
volume across redeploys. Process admission still requires the kernel policy in
[Tiers and guarantees](https://docs.hermitbox.dev/v0.2.4/hosting.md#tiers-and-guarantees); no user namespace, delegated cgroup, Docker
or KVM is assumed.

[Templates](https://docs.railway.com/templates),
[variable functions](https://docs.railway.com/variables/reference),
[volumes](https://docs.railway.com/volumes), [pricing](https://railway.com/pricing).
