---
url: https://kit.kambium.net/docs/setup.md
---
# Environments and secrets

Keep development work separate from production by configuring each environment
with its own services and credentials.

The default Fly.io setup uses one Fly app per environment. Desktop and the CLI
read `fly.toml` for a single target. To add a named target, run this from your
app directory with your intended Fly app name.

```sh
npm exec -- kambium backend setup --env dev --fly-app my-app-dev
```

This creates `fly.dev.toml` and adds a `fly:deploy:dev` script to
`package.json`. Deploy with `npm run fly:deploy:dev` after configuring the
Fly app. Use the same setup command to add a missing script for an existing
TOML. Commit both files. When named targets exist, Desktop and the Kit CLI
use those targets. Give each named environment its own Fly app.

In Desktop, pick an environment below the **Cloud** tab. The menu next to the
picker opens **Manage environments**, which lists each Fly app, TOML file and
secrets provider.

Save commit-safe settings such as the app URLs in the selected file's `[env]`
table. Put private runtime values in that Fly app's secrets. Desktop stages
private values and applies them on the next deployment. Follow the
[Fly deployment guide](https://kit.kambium.net/docs/deployment.md) to set up the app.

<span id="doppler"></span>

::: details Manage secrets in Doppler

With the Doppler CLI installed, select an environment in the Cloud sidebar.
In **Configuration**, choose **Change secrets provider** on the Fly sign-in screen,
or open **Secrets provider options** and choose **Doppler** if you're signed in to Fly.
Sign in to Doppler through your browser.
Select the Doppler project and configuration, then confirm **Switch to Doppler**.
Switching changes where Desktop saves future settings. Copy the existing values
you need into Doppler, then set up a sync from that config to the matching Fly app.
Use separate configs for development and production. [Doppler Fly sync setup](https://docs.doppler.com/docs/flyio)

Desktop saves private values to Doppler, including generated keys, the Supabase
backend key, and the Redis connection URL. Public settings still go in the Fly
TOML's `[env]` table. Sign in to Fly to create an app or Redis database, check
the synced values' deployment status, or deploy.

The Configuration count reflects the settings in Doppler and TOML. **Review
deployment** checks which required settings have reached Fly. If a sync is still
in progress, refresh and review again after it completes. Turn off the sync for
the app in Doppler before switching its secrets provider back to Fly.

To run code on your computer with the same development credentials, see
[Run locally with hosted services](https://kit.kambium.net/docs/local-development.md#development-with-hosted-services).

:::

<span id="services"></span>
<span id="supabase"></span>

## Service roles

```mermaid
flowchart TD
  accTitle: Default Kambium Kit production deployment
  accDescr: The browser sends dashboard and API requests to one Fly.io app. That app serves the Vue dashboard and runs the API and workers. It uses Supabase for Auth and Postgres and Redis for caching and coordination.
  browser[User browser] -->|Dashboard and API requests| fly
  fly["One Fly.io app<br/>Vue dashboard, API and workers"] --> supabase["Supabase<br/>Auth and Postgres"]
  fly --> redis["Redis<br/>Caching and coordination"]
```

* One Fly.io app runs the API and background workers and serves the Vue dashboard
  by default. [Deploy to Fly](https://kit.kambium.net/docs/deployment.md)
* Supabase provides Auth and Postgres, which stores workspaces, engines and
  queued tasks. [Set up Supabase](https://kit.kambium.net/docs/cloud-supabase.md)
* Redis handles caching and coordination. Desktop can create a managed Upstash
  database in your Fly organization or connect an existing Redis instance.
  [Connect Redis](https://kit.kambium.net/docs/cloud-fly.md#connect-redis)
* For production sign-in email, configure SMTP in Supabase or use Kit's optional
  Postmark email hook. [Configure sign-in email](https://kit.kambium.net/docs/verify-deployment.md#configure-supabase-auth)

[Sentry](https://kit.kambium.net/docs/cloud-sentry.md) reporting is optional.

<span id="docker"></span>
<span id="domains-and-checks"></span>

::: details Use another deployment host

Install private npm package read credentials on the build host. Commit the app's
source, `package.json` and `package-lock.json`; use `npm ci` for subsequent builds.
From the app directory, run `npm run build`, then start with `npm start`.

Build the generated Docker image from the app directory:

```sh
docker build --secret id=npmrc,src="$HOME/.npmrc" -t my-app .
```

The npm configuration must contain usable private registry credentials. Supply
the required runtime settings through the host's secret store and publish port
`3000`. The image runs Node as a non-root user. Docker mounts the registry
credentials during dependency installation.

Serve the backend and dashboard through HTTPS, configure proxy trust for the
host and provide the [dashboard's API routing](https://kit.kambium.net/docs/dashboard-deployment.md).
Keep the backend running for background jobs with a supervisor that forwards
SIGTERM and allows more than ten seconds for shutdown. Rebuild after source
changes and restart after changing settings.

Follow [deployment verification](https://kit.kambium.net/docs/verify-deployment.md) for callbacks and engine
checks, and [updates and rollback](https://kit.kambium.net/docs/updating.md#hosted-migrations-and-rollback)
for later releases.

:::

<span id="authorization-and-locking"></span>
<span id="updates-and-rollback"></span>
<span id="development-with-hosted-services"></span>

For local code using shared development infrastructure, see
[Run locally with hosted services](https://kit.kambium.net/docs/local-development.md#development-with-hosted-services).
