> ## Documentation Index
> Fetch the complete documentation index at: https://docs.opencomputer.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Single VM

> Run @computer on one Ubuntu VM with Podman, for a quick proof of concept or for one practitioner

This setup is for a quick proof of concept, and for individual practitioners who want to use coding agents on a machine they control. It is not built for a team that depends on it. For that, use the [Azure](https://docs.opencomputer.dev/self-hosting/azure.md), [AWS](https://docs.opencomputer.dev/self-hosting/aws.md) or [Google Cloud](https://docs.opencomputer.dev/self-hosting/gcp.md) deployments.

Everything runs on one VM:

* **The gateway** runs the hosted service's code in a container, under Miniflare. Miniflare is a local emulator of Cloudflare's Durable Objects, D1, R2 and KV. The gateway also serves the web dashboard, with WorkOS sign-in and without billing.
* **The host agent** runs on the same VM. Each session runs in its own rootless Podman container.
* **`/setup`** is a browser page where you add the Claude credential, connect the host, and set up sign-in and Slack.

## Requirements

* **Ubuntu 24.04 on x86-64.** The host installer refuses arm64, and it refuses other distributions. Ubuntu 22.04 works only with Podman 4.7 or newer and `passt`.
* **Free space under `/data`:** the installer warns below 20 GiB. The session image takes about 10 GiB, and every session's workspace needs more.
* **A Claude credential:** an Anthropic API key (`sk-ant-api…`), or a subscription token from `claude setup-token` (`sk-ant-oat…`).
* **For the dashboard and Slack:** a public HTTPS URL for the gateway. See [HTTPS](#https).
* **For the dashboard:** a [WorkOS](https://workos.com) account.

## 1. Install the host

As a user with `sudo`:

```sh theme={null}
git clone https://github.com/diggerhq/opencomputer.git ~/oc-host
cd ~/oc-host
sudo selfhost/host-install.sh --dry-run   # checks the machine and prints the plan
sudo selfhost/host-install.sh
```

The installer sets up the following:

* Node.js and rootless Podman
* `podman-compose` 1.6.0 in `/opt/podman-compose`
* the `slack-presence-host` service and the model proxy
* the `oc-gateway` user (home `/var/lib/oc-gateway`, lingering enabled), which runs the gateway
* the gateway's files in `/var/lib/oc-gateway/selfhost`, copied from your checkout and owned by `oc-gateway`
* the gateway image, pulled from `ghcr.io/diggerhq/computer-gateway` and pinned in `compose.yaml` to the build of your checkout's gateway source (`:src-<hash>`, from `selfhost/gateway/source-tag.sh`)
* `opencomputer-imds-deny`, which denies the cloud instance metadata service (169.254.169.254, and `fd00:ec2::254` and `fd20:ce::254` over IPv6) to every user but root, on any cloud. DNS (port 53) and NTP (UDP 123) to that address stay open, because Google Cloud serves both there. A non-root program of your own that reads the metadata service stops working; run it as root. `sudo selfhost/check-imds.sh` checks the rule.

CI publishes the gateway image only after a change to the gateway's source reaches `main`. If your checkout's image isn't published, for example on a branch with its own gateway changes, the installer stops and says so. Add `--build-gateway` to build it on the VM instead, which takes 20 to 30 minutes.

The host agent doesn't start yet, because `/etc/opencomputer/selfhost.env` has no token. Step 4 adds it.

## 2. Configure the gateway

As `oc-gateway`:

```sh theme={null}
sudo -iu oc-gateway
cd ~/selfhost
cp .env.example .env && chmod 600 .env
```

Set these in `.env`:

| Variable | Value |
| - | - |
| `SETUP_TOKEN` | Required. The operator's credential for `/setup` and the API. Generate it with `openssl rand -hex 32`. |
| `PUBLIC_URL` | The public HTTPS origin, with no trailing slash, for example `https://computer.example.com`. The dashboard and Slack need it, and you can leave it empty until then. |
| `GATEWAY_PORT` | The gateway's port on `127.0.0.1`. The default is `8080`. |
| `GATEWAY_ORG` | The organization ID. The default is `org_selfhost`. Don't change it after the first start. |
| `SP_SETUP_OPEN` | Set it to `1` to keep `/setup` open after **Finish setup**. Otherwise leave it empty. |
| `SP_SETUP_REMOTE` | Set it to `1` to allow `/setup` through `PUBLIC_URL`, not only through an SSH tunnel. Not recommended. Otherwise leave it empty. |
| `GATEWAY_IMAGE` | Leave it empty to run the image the installer pinned. To run another image, set a tag or an `@sha256:` digest, such as `ghcr.io/diggerhq/computer-gateway:v1.2.3`, not `:main`. Then run the installer again so it pulls the image. |

## 3. Start the gateway

Install the systemd user unit. It runs `podman-compose up` in the foreground and restarts it whenever it exits. Still as `oc-gateway`:

```sh theme={null}
install -D -m 0644 ~/selfhost/systemd/opencomputer-gateway.service \
  ~/.config/systemd/user/opencomputer-gateway.service
systemctl --user daemon-reload
systemctl --user enable --now opencomputer-gateway.service
```

The installer already pulled the gateway image, so the gateway starts in seconds. Then `curl -s 127.0.0.1:8080/healthz` returns `{"ok":true,"mode":"miniflare"}`.

Stop the gateway with `systemctl --user stop opencomputer-gateway`. If you use `podman stop`, systemd starts it again. To try the gateway in the foreground without the unit, run `podman-compose up` from `~/selfhost`.

## 4. Connect the host

As the sudo user, from the host checkout:

```sh theme={null}
cd ~/oc-host && sudo selfhost/host-install.sh --link-gateway
```

This reads the gateway container's `GATEWAY_ORG`, `GATEWAY_PORT` and `/data/host-token`. It writes `SP_GATEWAY_URL`, `SP_HOST_ID` and `SP_HOST_TOKEN` to `/etc/opencomputer/selfhost.env` (root, mode 0600), then starts `slack-presence-host`. The token is never printed. The host dials `ws://127.0.0.1:<GATEWAY_PORT>/v1/computer/host?organizationId=<GATEWAY_ORG>`.

The Host step of `/setup` shows an equivalent command, with the token masked until you select **Reveal the command with the token**. That command replaces all of `selfhost.env`, and it puts the token on your command line. Prefer `--link-gateway`.

## 5. Set up in the browser

`/setup` answers only on the VM itself, never through `PUBLIC_URL` or a tunnel. Open it through an SSH tunnel:

```sh theme={null}
ssh -L 8080:127.0.0.1:8080 you@vm
```

Then open `http://localhost:8080/setup`. To allow it through `PUBLIC_URL` as well, set `SP_SETUP_REMOTE=1` in `.env` and restart the gateway. We don't recommend it: anyone who can reach the URL gets the sign-in page.

Sign in with `SETUP_TOKEN`. The sign-in lasts 12 hours, and changing `SETUP_TOKEN` ends it. Scripts can send `Authorization: Bearer <SETUP_TOKEN>` instead.

The page has these sections:

1. **Claude credential** (required). Paste the key or token. It is stored encrypted and is never shown again. Sessions never see it: only the host's model proxy uses it.
2. **Host** (required). It shows **connected** once step 4 is done. Select **I'll connect the host later** to finish without it.
3. **Sign-in and people** (optional). The WorkOS app for the dashboard. See [Dashboard](#dashboard).
4. **Slack app** (optional). See [Slack](#slack).
5. **OIDC** (optional). Stored only.
6. **GitHub App** (optional). Stored only.

Once the Claude credential is set and the host is connected or acknowledged, set up sign-in and Slack below if you want them, then select **Finish setup** at the bottom of `/setup`. Saving the required steps alone never closes setup. After you finish, every `/setup` URL returns 404. To change something later, set `SP_SETUP_OPEN=1` in `.env` and restart the gateway. When you're done, clear it and restart again.

## Dashboard

The dashboard is at `PUBLIC_URL`, which must be an HTTPS origin.

1. In the [WorkOS dashboard](https://dashboard.workos.com), under **Redirects**, add `<PUBLIC_URL>/auth/callback`. `/setup` shows the exact value.
2. In the **Sign-in and people** section of `/setup`, paste the WorkOS client ID and API key, add the owner's email, then select **Save**.
3. Open `PUBLIC_URL` and sign in with the owner's email.
4. To add people, go to **Settings**, then **Members**, and select **Invite**. WorkOS emails the invitation, and the person signs in with that address. Nobody else can sign in.

Sessions start from **Computer** in the dashboard once the Claude credential is set and the host is connected. Anyone in a connected Slack workspace can also use @computer, whether or not they're invited.

## Slack

Slack needs `PUBLIC_URL` set to an HTTPS origin.

1. In `/setup`, open the **manifest** link. At [api.slack.com/apps](https://api.slack.com/apps?new_app=1), choose **Create New App**, then **From a manifest**, and paste it.
2. From the app's **Basic Information** page, paste the client ID, the client secret and the signing secret into `/setup`, then select **Save**.
3. Select **Install to Slack** and approve.

To start a session, mention the app in a channel or DM it.

## Attachments

Files that people attach to a message are stored in the gateway's volume, and the gateway serves them itself. Nothing needs to be set up. A browser uploads to and reads from a short-lived signed URL on the address it opened the dashboard at. Sessions read attachments at `PUBLIC_URL`.

To keep attachments in an S3-compatible store instead (Cloudflare R2, Amazon S3, MinIO), set these in `.env` and restart the gateway:

```sh theme={null}
ATTACHMENTS_S3_ENDPOINT=https://<account>.r2.cloudflarestorage.com
ATTACHMENTS_S3_BUCKET=attachments
ATTACHMENTS_S3_ACCESS_KEY_ID=…
ATTACHMENTS_S3_SECRET_ACCESS_KEY=…
ATTACHMENTS_S3_REGION=auto   # optional; `auto` is the default, for R2
```

All four of the first values are needed; with any missing, the gateway uses its volume. The bucket's CORS must allow `PUT`, `GET` and `HEAD` from any origin, with the `content-type` and `range` headers. Files already stored in the volume are not copied to the bucket.

## HTTPS

The gateway listens only on `127.0.0.1`. To expose it, run a Cloudflare Tunnel on a custom domain, which needs no inbound ports:

1. In Cloudflare Zero Trust, create a named tunnel.
2. Add a public hostname on your domain, for example `computer.example.com`, with the service `http://gateway:8080`.
3. In `.env`, set `CLOUDFLARE_TUNNEL_TOKEN` to the tunnel's token and `PUBLIC_URL=https://computer.example.com`.
4. Enable the `cloudflared` profile. Run `systemctl --user edit opencomputer-gateway`, add the lines below, then run `systemctl --user restart opencomputer-gateway`.

```ini theme={null}
[Service]
Environment=COMPOSE_PROFILES=cloudflared
```

Any other reverse proxy that terminates TLS in front of `127.0.0.1:8080` also works.

## Back up and restore

All of the gateway's state is in the `opencomputer_gateway-data` volume:

* Miniflare's data, including attachments (unless an S3-compatible store holds them)
* `keys.json`, which decrypts the stored secrets
* `host-token`

Store the backup encrypted. As `oc-gateway`:

```sh theme={null}
systemctl --user stop opencomputer-gateway
podman volume export opencomputer_gateway-data > gateway-data-$(date +%F).tar
systemctl --user start opencomputer-gateway
```

To restore, stop the gateway first, then recreate the volume from the backup and start the gateway again:

```sh theme={null}
systemctl --user stop opencomputer-gateway
podman volume rm -f opencomputer_gateway-data   # -f also removes the stopped container
podman volume create opencomputer_gateway-data
podman volume import opencomputer_gateway-data gateway-data-<date>.tar
systemctl --user start opencomputer-gateway
```

Session workspaces live on the host under `/data`, outside the volume. Back them up with disk snapshots.

## Upgrade

Back up the volume first. The gateway applies new database migrations when it starts.

```sh theme={null}
# as the sudo user: updates the host and the gateway's files in /var/lib/oc-gateway/selfhost (.env is kept),
# and pulls the gateway image of the new checkout (--build-gateway: builds it instead)
cd ~/oc-host && git pull && sudo selfhost/host-install.sh

# as oc-gateway
systemctl --user restart opencomputer-gateway
```

## Troubleshooting

| Symptom | Check |
| - | - |
| `/setup` returns 404 through the public URL | `/setup` is local only. Open it through `ssh -L 8080:127.0.0.1:8080 you@vm` at `http://localhost:8080/setup`, or set `SP_SETUP_REMOTE=1` (not recommended). |
| `/setup` returns 404 | Setup is finished: set `SP_SETUP_OPEN=1` and restart the gateway. Also check that `SETUP_TOKEN` is set in `.env`. |
| Sign-in loops back to the sign-in page | `PUBLIC_URL` is `https://…` but you opened `http://`, so the browser drops the `Secure` cookie. Open `PUBLIC_URL` instead. |
| The dashboard says "Sign-in isn't set up yet." | Save the WorkOS app in the **Sign-in and people** section of `/setup`. |
| WorkOS rejects the redirect URI | Add `<PUBLIC_URL>/auth/callback` under **Redirects** in WorkOS. |
| "You aren't a member of this OpenComputer." | The owner invites that email from **Settings**, then **Members**. |
| The host stays **not connected** | Run `sudo journalctl -u slack-presence-host`, then `sudo selfhost/host-install.sh --link-gateway` again. |
| Sessions reply "No model credential is configured for this computer." | Set the Claude credential in `/setup`. |
| There is no **Install to Slack** button | Save all three Slack values first. |
| The gateway restarts in a loop | As `oc-gateway`, run `podman logs opencomputer_gateway_1` and `systemctl --user status opencomputer-gateway`. |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.