---
url: https://kit.kambium.net/docs/deployment.md
---
# Deploy to Fly

<span id="deploying-to-flyio"></span>
<span id="before-you-start"></span>

Deploy the Vue dashboard and Fastify backend together on Fly.io from Kambium Desktop.

## Deploy a newly generated app

1. In **Cloud → Project setup**, install the required tools and app dependencies.
   In **Cloud → Fly**, connect Fly and
   [create or select the Fly app](https://kit.kambium.net/docs/cloud-fly.md) named in your environment file.
   Save the backend and dashboard URLs. Both can use `https://YOUR_APP.fly.dev`.
2. [Connect Redis](https://kit.kambium.net/docs/cloud-fly.md#connect-redis), then
   [connect Supabase](https://kit.kambium.net/docs/cloud-supabase.md), review its database migrations, and configure sign-in URLs. Add the remaining
   [runtime settings](https://kit.kambium.net/docs/environment-variables.md#required-settings), including a
   stable webhook prefix and encryption keys. Desktop saves commit-safe settings
   to the Fly TOML and stages private settings on the selected Fly app.
3. In **Cloud → Deployment**, Desktop runs readiness checks automatically.
   When the checks pass, choose **Review deployment** and confirm the release.
   After deployment,
   [configure callbacks and verify](https://kit.kambium.net/docs/verify-deployment.md).

For terminal deployment or a custom domain, see
[Deploy the dashboard](https://kit.kambium.net/docs/dashboard-deployment.md#host-the-dashboard-on-fly).
If you need to use a different host, see
[Use another deployment host](https://kit.kambium.net/docs/setup.md#docker).

<span id="package-access"></span>

::: details Desktop reports missing package access

Sign in to npm locally with an account that can read the Kit packages, then
refresh Deployment:

```sh
npm login --registry=https://registry.npmjs.org/
```

The build uses registry packages from your lockfile.

:::

::: details Deploy the backend with the Fly CLI directly

From your app directory, use the Fly CLI. Set `app` in `fly.toml` to the intended
Fly app. New apps select `Dockerfile.go-ingress`, with Go listening on port
3000 and Fastify on loopback. Sign in to Fly in the terminal and configure public
IPs if your app needs them. [Fly public network services](https://fly.io/docs/networking/services/)

Supply the [backend settings](https://kit.kambium.net/docs/environment-variables.md#required-settings) to
Fly's runtime environment. For a newly generated app, generate
`WEBHOOK_PATH_PREFIX` once with `node -p 'require("node:crypto").randomBytes(12).toString("base64url")'` and keep it with that
environment's runtime secrets. Build with an npm configuration that can read
the Kit packages.

```sh
fly deploy --ha=false --build-secret "npmrc=$(cat "$HOME/.npmrc")"
```

The generated Dockerfile uses the npm configuration during dependency
installation. The deployed image reads runtime settings from Fly. For another
container host, see [Docker deployment](https://kit.kambium.net/docs/setup.md#docker).

:::

::: details Check an interrupted deployment

If a deployment fails or is cancelled, check the selected app's release status
in Fly before retrying. Settings may have been staged or the remote deployment
may have completed.

:::

<span id="scaling"></span>

::: details Scaling to multiple backend replicas

Run copies of the same backend behind one public API URL. Use the same Supabase
project, Redis instance, engine registrations, encryption keys and webhook
prefix on each replica.
For a starter Fly app deployed on one Machine in one region, run this from your
app directory to bring it to two Machines. [Fly scale reference](https://docs.fly.io/flyctl/cmd/fly_scale_count)

```sh
fly scale count 2
```

* **Task queue.** Workers share one Postgres queue and claim due tasks atomically.
  Replicas can compete for work from that queue without assigning partitions.
  Worker concurrency limits apply per process and add up across replicas.
* **Distributed locks.** Kit uses Postgres locks to coordinate recovery sweeps
  and built-in Airtable webhook maintenance. Per-engine locks serialize Airtable
  activation and webhook processing. Engine `setup` runs on every replica, and
  custom cron jobs run on every replica with jobs enabled. Use shared coordination
  for custom work that must run exclusively.
* **Replica failure.** Keep scheduled jobs enabled on a running replica so it can
  pick up pending work and recover stale task claims. If a replica dies holding a
  recovery lock, the next sweep can acquire it after the lease expires, 15 minutes
  after acquisition. Make external writes safe to retry. [Task recovery](https://kit.kambium.net/docs/tasks.md#retry-and-recovery-boundaries)

:::

::: details Archive the deployed image's SBOM on GitHub

Create a GitHub release tagged `deployment-sboms` in the app's GitHub origin
repository. Use a release that accepts asset uploads after publication. Install
[Syft](https://oss.anchore.com/docs/guides/sbom/getting-started/) and the
[GitHub CLI](https://cli.github.com/), sign in with `gh auth login`, and run
`fly auth docker` with access to the app's Fly organization.

Run `npm run fly:deploy -- --upload-sbom`. After Fly deploys, the CLI
generates a CycloneDX SBOM from the matching image and uploads it to the
displayed repository. The asset name includes the Fly app, release number,
and image digest.

If the upload fails, run the retry command printed by the CLI. You can retry
while the release and its image are still available from Fly.

:::

## Security

Generated apps include sign-in, workspace and engine access controls, and
encryption for stored provider credentials. Kit verifies signatures for
supported webhooks when configured.

On Fly, new apps use Go ingress to check incoming requests before they reach
the backend. As the app owner, you manage deployment secrets and add access
checks to any custom routes you create.

[Request a security overview](https://kit.kambium.net/security-overview)
for a private review of these protections.

<span id="ip-allowlists"></span>

## Restrict database access

Redis created through Fly uses your Fly organization's private network. Use
the private connection URL from [Cloud → Redis](https://kit.kambium.net/docs/cloud-fly.md#connect-redis).
[Fly Redis networking](https://docs.fly.io/upstash/redis)

Supabase network restrictions cover direct and pooled Postgres connections.
If you enable them, allow the outbound IPs of each app, operator and CI runner
that connects to Postgres. Check connectivity from the environment that runs
migrations. The generated backend talks to Supabase over HTTPS, which has
its own access controls. [Supabase network restrictions](https://supabase.com/docs/guides/platform/network-restrictions)

::: details IP allowlisting for standalone Upstash

Allocate app-scoped static outbound IPs for each Fly region that runs your
backend. Add each outbound IPv4 address to the Upstash allowlist, along with
the outbound addresses of any other Redis clients. Check connectivity from
each backend region. [Fly static outbound IPs](https://docs.fly.io/networking/egress-ips) ·
[Upstash IP allowlists](https://upstash.com/docs/redis/howto/ipallowlist)

:::

## Updates

Repeat **Deploy to Fly** after applying required migrations and reviewing
compatibility with the running app. See [Update your application](https://kit.kambium.net/docs/updating.md)
for the rollout and rollback steps.

<span id="roll-back-the-backend"></span>

::: details Roll back the backend on Fly

After confirming the previous build supports the currently applied schema and
stored data, list releases and deploy the chosen image:

```sh
fly releases --app YOUR_FLY_APP --image
fly deploy --app YOUR_FLY_APP --image PREVIOUS_IMAGE --ha=false
```

Replace `PREVIOUS_IMAGE` with the full registry image reference from the list.
The image must still exist in the registry. This reuses the current `fly.toml`
and runtime secrets. Restore compatible runtime settings separately. Rolling
back a combined image restores the dashboard and backend together. If you host
the dashboard separately, restore its previous build as needed.
Repeat the health and engine checks after rollback. It does not undo database
changes. See [Fly's rollback guide](https://docs.fly.io/blueprints/rollback-guide).

:::
