# Dormice

Install Dormice and prepare the gateway URL and API token that let Sandcovery run sandboxes on your own Linux host.

Sandcovery creates each sandbox on a [Dormice](https://github.com/BitMiracle-AI/Dormice) gateway that you run, through Dormice's HTTP API and a token you add as the credential. Dormice is free, open-source software under the Apache License 2.0, and it has no hosted service, so Sandcovery runs no Dormice of its own.

## What runs

| Option | Support |
| --- | --- |
| Size | 1 to 8 vCPUs, set per sandbox, within what your host has free |
| Disk | Your fleet's per-sandbox disk setting |
| Egress | `allow_all`, within your host's own network rules |
| Environment variables | On each command, not at create |
| Lifetime | Until Sandcovery destroys the sandbox at its TTL |
| Pause and resume | No, Dormice freezes an idle sandbox and any call wakes it |
| Region | Your host's location |

Command output over 1 MiB, files over 16 MiB, snapshots, port previews, custom images, idle timeouts, disk sizes, egress limits, and GPUs are not available on this provider. A create or call that asks for one routes to another provider or fails as unsupported.

Commands run to the end and answer once, so a streamed command returns its whole output when it finishes.

## Install Dormice

Install Dormice on a Linux x86_64 host with Docker and gVisor as the [README](https://github.com/BitMiracle-AI/Dormice#readme) describes, and run `dor doctor` to check the host. The README says Dormice is in early development.

## Create an API token

Mint a key for Sandcovery with the `createApiKey` call, which prints its 64-character token once:

```sh
curl -X POST http://127.0.0.1:3677/createApiKey \
  -H "Authorization: Bearer $DORMICE_API_TOKEN" \
  -H "content-type: application/json" \
  -d '{"name": "sandcovery"}'
```

A key opens every call Sandcovery makes and can be disabled or revoked at any time through `updateApiKey` or `revokeApiKey`.

## Reach the gateway

Dormice's gateway and daemon listen on `127.0.0.1` only. Sandcovery calls your gateway from Cloudflare Workers, which accept only a certificate from a public certificate authority, so put the gateway behind a reverse proxy with a publicly trusted certificate, such as Caddy, which the README shows:

```
your-domain.example {
	reverse_proxy 127.0.0.1:3677 {
		flush_interval -1
	}
}
```

The URL must use `https` with no user, query, or fragment, and it can hold a path.

## Add the credential

In **Provider Credentials** in the [dashboard](/app/credentials), add these two fields for Dormice:

- Gateway URL: the `https` URL of your reverse proxy
- API token: the token `createApiKey` printed

## Costs

Dormice is free software under the Apache License 2.0, so Sandcovery lists it at $0 for every size, and its estimates and spend limits count its sandboxes at $0. Your host bills whatever its provider charges, which Sandcovery does not read.
