Runners and agents
Runners in the cloud
Run a runner on a cloud VM with a pasted script, or on a container platform with the runner image.
A runner on a machine that’s always on keeps working while your laptop sleeps. There are two ways to put one in the cloud:
- A VM (EC2, Compute Engine, Hetzner, DigitalOcean, Azure): paste a script into the VM’s user data when you create it. It installs the runner as a systemd service.
- A container platform (Render, Railway, Fly.io, Kubernetes, Compose): run the runner image with a volume and a few variables.
On Add a runner, choose A cloud VM or A container platform, then your provider. Either way the runner is yours: it’s registered with your one-time code and runs only your jobs, with no sandbox (see Where to run a runner).
On a VM#
Choose A cloud VM, what the runner will run, its name and your provider. More options sets how many jobs it runs at once, can add a second runner as a user of its own, and puts a model credential in the script. The page builds the VM’s user data:
#!/bin/sh
export ANTHROPIC_API_KEY='…'
curl -fsSL https://moru.example.com/install-runner.sh | sh -s -- --service --name cloud-1 --code mrr_… --max-jobs 2 The page says where your provider takes it when you create the VM:
| Provider | Field |
|---|---|
| AWS | Advanced details → User data |
| GCP | Advanced → Automation → Startup script |
| Hetzner | Cloud config |
| DigitalOcean | Additional options → Startup scripts (user data) |
| Azure | Advanced → Custom data |
For Other Linux, run the script as root on the machine, or paste it into your provider’s user data.
The VM needs Linux with systemd (x86_64 or arm64). The script runs as root when the VM boots. The code expires 15 minutes after the page made it, so the VM has to boot and start the runner by then; the page shows how long is left, and gets a new code by itself once one has expired. If the VM didn’t make it in time, use the new script.
The page builds the script in your browser. It never sends it to the node, so the node never sees the credential.
The credential is optional. If you fill it in, the script exports it and the setup
writes it into a file only root can read. Your cloud provider keeps user data, shows it
in its console, and serves it to the VM’s metadata service, where agents on the VM can
read it. To keep it out of user data, leave the field empty. Once the VM is up, SSH in,
get a token with claude setup-token, add it to the runner’s env file (below) and
restart the runner.
A second runner, as a user of its own adds a second line with a code of its own, without the credential. It’s there when the first runner runs agents:
- For CI: a runner named
<name>-ciwith--kind ci, running as the usermoru-runner-ci. The first runner then leaves CI to it and takes only agent jobs (--kind implement --kind review). - For jobs that name it: a runner named
<name>-deploywith--only-named, running as the usermoru-runner-deploy, for deploys and jobs with secrets. Tick scheduled runs to add--schedules. The first runner keeps its CI.
The page waits for both to come online.
The installer passes the runner’s role on with --kind (repeatable), --only-named and --schedules. --schedules needs --only-named, and --only-named refuses a --kind other than ci.
What --service does#
install-runner.sh --service sets up a runner as a systemd service. It needs root and
Linux:
- Installs
gitwith apt, dnf or apk if it’s missing, andmoru-runnerinto/usr/local/bin. - Creates the system user
moru-runner(or the one--usernames), with its home in/var/lib/moru-runner. - Writes
/etc/moru-runner/<name>.env(mode 0600, owned by root) withMORU_NODE,MORU_RUNNER_CODE, the job count and role (MORU_KINDS,MORU_ONLY_NAMED,MORU_SCHEDULES), and whichever ofCLAUDE_CODE_OAUTH_TOKEN,ANTHROPIC_API_KEY,CODEX_API_KEYandGEMINI_API_KEYare set in the script’s environment. A credential never goes on a command line. - Installs the template unit
moru-runner@.service, with a drop-in for this runner that sets its user, and startsmoru-runner@<name>. The runner registers itself on its first start.
The runner keeps its key and token in /var/lib/moru-runner/.local/share/moru-runner/<name>. To look after it:
systemctl status moru-runner@cloud-1
journalctl -u moru-runner@cloud-1 -f
sudoedit /etc/moru-runner/cloud-1.env # then:
systemctl restart moru-runner@cloud-1 Stopping the unit stops the runner gracefully: it finishes its jobs first, for up to 30 minutes.
Running it again is safe. Compute Engine runs the startup script on every boot, and you can run the command again yourself to upgrade. Once the runner is registered, it ignores the code it registered with, so the same script works on every boot. The setup replaces the binary, updates the settings you passed (a credential in the environment replaces the one in the file), and restarts the unit. Run it with a new code to register the runner again (see below). One machine can hold several runners, each with its own name, code and user.
The role is one setting. Run it again with any of --kind, --only-named or --schedules, and the env file’s MORU_KINDS, MORU_ONLY_NAMED and MORU_SCHEDULES lines are rewritten: the ones you didn’t give are dropped. Give none, and the file keeps
its lines. So to move a registered runner to another role, run the installer again as
root, without a code, with the full role (Settings → Runners → Change what it runs gives the command):
curl -fsSL https://moru.example.com/install-runner.sh | sh -s -- --service --name cloud-1 --only-named --schedules --kind implement --kind review --kind ci spells out the default, all three.
The same works on any Linux server you can SSH into:
curl -fsSL https://moru.example.com/install-runner.sh | sudo ANTHROPIC_API_KEY=… sh -s -- --service --name cloud-1 --code mrr_…
On a container platform#
The runner image is quay.io/moru/moru-runner, tagged with each release’s
version and latest, for linux/amd64 and linux/arm64. Runner and node should match:
the page fills in your node’s version where the platform takes a tag.
| What | |
|---|---|
| Volume | One, at /data. It holds the runner’s key and token, agent logins, mise’s tools and caches. |
MORU_NODE | Your node’s URL. |
MORU_RUNNER_NAME | The runner’s name. |
MORU_RUNNER_CODE | The one-time code, for the first start. Keep it secret until then. |
| A model credential | CLAUDE_CODE_OAUTH_TOKEN, ANTHROPIC_API_KEY, CODEX_API_KEY or GEMINI_API_KEY, as a secret. |
MORU_MAX_JOBS | Optional: jobs at once. |
MORU_KINDS | Optional: the job kinds to take, comma-separated (implement,review or ci). |
MORU_ONLY_NAMED | Optional: true to take only CI jobs that name the runner, from pushes and manual starts. |
MORU_SCHEDULES | Optional, with MORU_ONLY_NAMED: true to take scheduled runs too. |
MORU_WORK_DIR | Optional: where CI jobs check out. |
MORU_CONTAINER_CLI | Optional: the container engine for CI jobs, or none. |
MORU_CI_CONFIG | Optional: the ci.toml with the runner’s CI secrets. |
| Port | None. The runner connects out to the node. |
The image is Debian with git, ca-certificates, curl, tini and mise. The runner downloads Claude Code itself. The runner runs
as uid 10001, with HOME=/data/home and XDG_DATA_HOME=/data/share, so its files are in /data/share/moru-runner/<name>. If the platform mounts the volume as another user, the
image gives it to uid 10001 when it starts.
Choose A container platform and your platform on Add a runner, and the page shows only that platform’s setup, with your node, name, code and job count filled in, and the model credential if you entered one under More options:
| Platform | What the page gives you |
|---|---|
| Render | A Deploy to Render button (template) and the values Render asks for. Disks need a paid plan. |
| Railway | The image and the variables for a Docker Image service with a volume (template). |
| Fly.io | fly launch, fly secrets set and fly deploy (template). |
| Kubernetes | The Secret and kubectl apply for a StatefulSet with one replica (template). |
| Docker Compose | A clone of the template, its .env, and docker compose up -d (template). |
| Other | The image and the variables above. |
One volume, one runner. Run one replica. Two replicas on one volume fail, since one runner holds the cache dir. A second runner needs a volume and a code of its own.
The image has no container engine, so it doesn’t take CI jobs with container:, services: or Docker actions; those go to your other runners. Compose could mount the
host’s Docker socket into the runner, but that makes every agent root on the host, and
no template does it.
Registering on first start#
moru-runner run --name NAME with MORU_RUNNER_CODE in its environment registers the
runner the first time, when no runner of that name is registered in its data dir, then
runs. Both setups above rely on this.
- The code is spent on the first start. It works once, within 15 minutes of when the page made it. Start the VM or deploy the service within that time.
- On a restart, the runner finds its key and token and ignores the code it registered with. It logs once that you can remove the variable. The used-up code left in a dashboard is harmless.
- A code that’s used up or expired stops the runner with an error that points to Add a runner → New code. Put the new code in
MORU_RUNNER_CODE(on a VM, in the env file or by running the setup again) and restart it. - A runner you revoked or deleted on Runners comes back
with a new code: put it in
MORU_RUNNER_CODEand restart the runner. A code it hasn’t registered with registers it again, with the key it has. - A lost volume means a lost key. Register again with a new code, and delete the old runner on Runners.
Adding tools to the image#
mise is in the image for the toolchains your jobs install with it. For anything else, such as Node.js and Codex, build your own image on top:
FROM quay.io/moru/moru-runner:latest
RUN apt-get update \
&& apt-get install -y --no-install-recommends nodejs npm \
&& rm -rf /var/lib/apt/lists/* \
&& npm install -g @openai/codex Use your image in place of the runner image, and set CODEX_API_KEY. Pin the same
version as your node instead of latest.
Containers for CI on a VM: rootless podman#
The VM setup doesn’t install a container engine. Without one, CI jobs with container:, services: or Docker actions go to your other runners. To run them on the
VM, add rootless podman for the runner’s user. This uses the CI runner from A second
runner → For CI, whose user is moru-runner-ci (moru-runner-deploy for For jobs
that name it); use moru-runner for a single runner.
Install podman as root.
On Debian or Ubuntu:
apt-get update && apt-get install -y podman passt uidmap On Fedora:
dnf install -y podman Give the user a range of subordinate user and group IDs. A system user doesn’t get one.
Pick a range no other line in /etc/subuid and /etc/subgid uses; check them first:
cat /etc/subuid /etc/subgid
usermod --add-subuids 200000-265535 --add-subgids 200000-265535 moru-runner-ci Let the user keep a runtime directory without a login, so podman finds /run/user/<uid>:
loginctl enable-linger moru-runner-ci
systemctl restart moru-runner@cloud-1-ci Then check the runner’s log:
journalctl -u moru-runner@cloud-1-ci | grep containers It says containers on: … with podman’s version. containers off: … says what’s
missing. The runner checks again every few minutes, so it also picks podman up without
the restart.
A container gives a job its own tools; it doesn’t isolate the job. See Containers on a CI runner.
Sizing#
An agent job mostly waits on the model, so a small VM or container (1–2 vCPUs, 2–4 GB of memory) runs a few at once. CI is what needs CPU and memory: size a CI runner for your builds and tests. Give the disk room for the repositories’ object cache, the toolchains and the build outputs.
Security#
- The code sits in provider configuration. Before the first start, anyone who can read the VM’s user data or the service’s variables could use it within its 15 minutes to register a runner that gets your jobs. Once it’s spent, it’s harmless.
- Metadata credentials. With no sandbox, agents can reach the cloud’s metadata service. Start runner VMs with no instance role and no service account.
- User data is visible. Providers keep it, show it in the console and serve it to the VM. Leave the credential out of it if that matters to you.
- No root in the image. The runner runs as uid 10001, and no template mounts a container engine’s socket.
- Model credentials stay with you and the provider. The node never sees them. Agents on the runner can read them, as on any runner.