# Compute providers

> Where previews run: a Namespace workspace, a Kubernetes cluster or a Docker host of yours, behind the same interface.

Stagd doesn't run previews itself. It tells your compute what to run, through one small interface every provider implements: create a preview's instance, check on it, deploy to it again, put it to sleep, wake it, read its logs and usage, and tear it down. Your `compose.yaml` and `stagd.yaml` describe the app the same way on each, so you can switch providers without rewriting anything.

## Providers

| Provider | Status | A preview is | Reached |
|---|---|---|---|
| Namespace | Available | A micro-VM of its own, running your compose app | Through Namespace's API, with a workspace token |
| Kubernetes | `beta` | A namespace of its own in your cluster (EKS, GKE, AKS, k3s, your own) | Through `stagd relay` in the cluster: no API server to open up |
| Docker host | `beta` | A compose project on a machine of yours: a VM, a server under a desk | Through `stagd relay` on the host: no public address needed |
| Fly.io | Planned | | |
| Azure Container Apps | Planned | | |
| Unikraft Cloud | Planned | | |

`stagd compute providers` lists the ones your Stagd server offers, and [Connect compute](https://stagd.dev/docs/guides/connect-compute.md) sets one up.

## What each does

| | Namespace | Kubernetes | Docker host |
|---|---|---|---|
| **Builds** | On the preview's instance | In the cluster with Stagd's BuildKit and registry, or pushed to a registry of yours | On the host |
| **A new commit** | Deploys onto the same instance, keeping its build cache and data | Deploys into the same namespace, keeping its volumes; what waits for a build keeps running the last commit until the build is done | Deploys onto the same compose project, keeping its build cache and volumes |
| **Sleep** | The instance is torn down; its volumes are kept in Stagd's storage meanwhile | Its workloads scale to zero; volumes stay in the cluster | Its containers stop; volumes stay on the host |
| **Wake** | A new instance, with the volumes put back before anything starts | Scaled up again | Started again |
| **One-shot services** (migrations, seeding scripts) | Run before what waits for them | Run as Jobs, before what waits for them | Run before what waits for them |
| **Where** | `eu` or `us`, at 2x4, 4x8 or 8x16 (vCPUs x GB) | Your cluster | Your host |
| **How long it may live** | Until the preview expires; each deploy moves the instance's deadline | No limit of its own | No limit of its own |

On every provider a sleeping preview wakes when someone opens its link, with its databases as they were.

## Databases and seeds

Databases Stagd runs (`services.postgres` and the others) live on a volume of the preview's, and a seed is restored when that volume is new.

- **Sleep keeps the data** everywhere.
- **A new commit keeps it too**: it deploys onto the preview's instance, namespace or compose project. When that's gone, or Namespace can't reuse its instance, the preview's events say why, and it's made again with its databases started over from their seed.
- **No provider can start a database from a snapshot yet**, so a large seed takes a while each time it's restored.
