Skip to Content

Deploy a backend

Ship a backend (and its dashboard) to Floor from your machine, then from GitHub on every push.

By the end of this page your backend runs on Floor's server at its own address, and every push to main deploys it again. You need a backend that builds (see Your first backend), the floor CLI signed in (see Install), and a project on Floor with the hostname you want to serve.

A deploy builds everything floor.toml names into one .floor release file, ships it to Floor, runs the backend's migrations, starts the new version next to the old one, and switches traffic once it answers. Nothing needs Docker or a registry.

1. Describe what ships in floor.toml

floor new already wrote a floor.toml next to your crate. For SAC's gate backend, with its dashboard on the same hostname:

project = "sac"
version = "1.5.0"                          # optional: else the backend crate's version

# The backend: the crate next to floor.toml.
[backend]
mount = "access-control.example.com/api"   # a hostname of the project, and the path it serves under
health = "/api/health"                     # must answer below 500 before it goes live (default /)
memory_mb = 256                            # default 256
cpu = 1                                    # cores (default 1)
# idle = "15m"                             # stop when idle, start on the next request or trigger
# outbound = ["api.github.com"]            # the only hosts it may reach (default: anywhere)
# build = "cargo build --release --locked" # the default

# The dashboard: built files, served at a whole hostname.
[[sites]]
name = "dashboard"
build = "bun install --frozen-lockfile && bun run build"
dir = "web/dist"
hostname = "access-control.example.com"
spa = true                                 # unknown paths get index.html
  • mount is a hostname, or a hostname and a path. The backend sees the whole path (/api/visits). Mounting it under the dashboard's hostname means the dashboard calls it without CORS.
  • project is the project's slug. The hostname must be one of the project's hostnames (Settings › General in the console, or floor projects update sac --host …, which replaces the list, so repeat --host for each).
  • [[sites]] is optional. A site serves a whole hostname from blob storage.
  • [[apps]] is for a program that isn't a Floor backend: a built folder and a run command, listening on $PORT. It takes the same health, memory_mb, cpu, idle and outbound keys.

The limits (memory_mb, cpu, idle, outbound) are explained in Sandbox and limits. Every key is listed in floor.toml.

If your queries use sqlx's checked macros (query!), run floor prepare and commit .sqlx/ first. floor deploy then builds with SQLX_OFFLINE=true and needs no database (Database).

2. Deploy from your machine

From the folder with floor.toml:

floor deploy

It builds each target, packs the release and ships it to production, then prints the deployment's log as it goes:

2 build variables from Floor
Building dashboard (bun install --frozen-lockfile && bun run build)
Building api (cargo build --release --locked)
/tmp/floor-releases/sac-1.5.0+3f2c1ab.floor (2 targets, 4180 KB)
Shipping sac-1.5.0+3f2c1ab to sac
api (0193a4c2-…)
  · From release sac-1.5.0+3f2c1ab
  · Migrating: ./gate --migrate
  · applied 0004 visit notes (sql, 12 ms)
  · Migrated in 0.6 s
  · Started floor-app@0193a4c2….service on port 41237
  · Answers /api/health with 200
  · Serving access-control.example.com/api
  · Ready
api 0193a4c2-…: https://access-control.example.com/api
dashboard 0193a4c3-…: https://access-control.example.com

The backend target is named api unless [backend] sets name. If a target fails, floor deploy prints its error and exits non-zero.

Floor runs Linux binaries. On Windows, deploy from WSL or from CI: a backend built on Windows won't start on the server.

Other forms of the same command:

floor deploy api                              # only the backend
floor deploy --env staging                    # to the staging environment (sac-staging)
floor build                                   # write the .floor file here, ship nothing
floor deploy sac-1.5.0+3f2c1ab.floor          # ship a file as it is

Deploying from a laptop uses your own Floor sign-in (floor login), so it needs an operator account. An operator can also make a token limited to deploys for one project: floor tokens create "deploys from my laptop" --area deploys:write --project sac.

3. Check that it's live

curl https://access-control.example.com/api/health
floor deployments list sac --target api

In the console, the project's Code › Deploys shows what's live per target and every deployment. A deployment's page has its details, history and deploy log.

4. Deploy from GitHub on every push

Each repository is linked to a project with the branch that deploys production. CI signs in with GitHub's own OIDC token, so the repository holds no Floor secret.

Link the repository (this needs a Floor operator):

floor deployments link sac acme/access-control --branch main

Or link it in the console under Settings › General › Repository.

Then add a workflow to the repository, .github/workflows/deploy.yml, that calls Floor's reusable workflow:

name: Deploy
on:
  push: { branches: [main] }
  workflow_dispatch:
permissions:
  id-token: write          # lets the job ask GitHub for its OIDC token
  contents: read
jobs:
  floor:
    uses: alihussnainrb/floor/.github/workflows/floor-deploy.yml@main
    with:
      floor-url: https://usefloor.dev
      bun: true            # set up Bun for the dashboard's build command

Push to main. The run's log shows the same lines as floor deploy, starting with Signed in as acme/access-control, deploying to sac.

The reusable workflow takes these inputs:

InputDefaultWhat it does
floor-url(required)Floor's URL; also the audience of the OIDC token
bunfalseSet up Bun for build commands
build""A build step of your own before floor.toml's; it gets Floor's variables too
targets""Only these targets from floor.toml, space-separated
configfloor.tomlPath to floor.toml
floor-versionlatestThe floor CLI version to install, e.g. 0.3.0

It installs the CLI from Floor itself, sets up Rust with a build cache, runs floor deploy, and keeps the .floor file as a run artifact for 14 days. Without id-token: write, the run can't get its OIDC token and the deploy stops with a message saying so.

Pull requests don't deploy. To deploy a staging branch to a staging environment, see Environments.

5. Give the build and the backend their variables

Variables and secrets live in Floor, per environment, not in GitHub. Build commands get them as environment variables, so VITE_API_URL reaches a Vite build. The backend gets them as environment variables when it starts.

floor deployments set-var sac VITE_MAPS_KEY pk_… --env production
floor deployments set-var sac GATE_VENDOR_TOKEN … --env production --secret
floor deployments vars sac

Secret values are never shown again and are masked in CI logs. A change applies on the next deploy. In the console: Settings › Variables and secrets.

A backend can also read project secrets at run time with cx.secret("NAME") (set them with floor secrets set sac NAME, which reads the value from stdin).

To use Floor's variables in a build step of your own, floor build-env adds them to $GITHUB_ENV in GitHub Actions (secrets masked), or prints them as export lines elsewhere.

What a deploy does

  1. Build. floor.toml's build commands run with the environment's build variables. The backend is built with cargo build --release --locked.
  2. Pack. Everything goes into one release file, sac-1.5.0+3f2c1ab.floor: a tar with a manifest (floor.json: project, release, commit, branch, each target, and each part's size and SHA-256) and a .tar.gz per target. The backend's part is its binary.
  3. Ship. The file goes to POST /v1/projects/sac/bundles. Floor checks every part against the manifest before anything deploys, keeps the last 5 files per project, and starts one deployment per target.
  4. Migrate. For a backend, Floor runs <backend> --migrate once, in the new release's sandbox with its variables (floor-migrate@<deployment>.service). Each migration it applies shows in the deploy log. If one fails, the deploy stops and the old version keeps serving.
  5. Start. The new version starts as floor-app@<deployment>.service, next to the old one, with its link to Floor's engine, DATABASE_URL and variables.
  6. Health check. Floor waits for the health path to answer with a status below 500. If it doesn't within 90 seconds, or the process exits, the deploy fails and the log shows its last lines.
  7. Swap. The route and the engine's triggers switch to the new version, then the old one drains (up to 30 seconds for requests in flight) and stops. A deploy drops no requests.

Sites go to blob storage under the deployment's own folder, and the hostname switches to them at once.

How CI signs in

  • The exchange. The workflow asks GitHub for an OIDC token whose audience is floor-url, and trades it at POST /v1/deploy-tokens/github.
  • What Floor checks. GitHub's signature, the issuer, the audience and the expiry. The run must be a push or a manual run (workflow_dispatch) on a branch linked to the project or one of its environments. Pull requests and other branches get nothing.
  • The deploy token. It lasts an hour, opens only deploy routes, and is for the one environment its branch is linked to.

The Floor GitHub App

When your Floor's GitHub App is installed on a repository, each deployment from its CI reports back to GitHub:

  • A check run per target on the commit, Floor · <target>. It stays in progress until the deployment is live, then succeeds with a link to it, or fails with its log.
  • A GitHub deployment with statuses, so production and each environment show under the repository's Environments.

Reporting is best effort: GitHub being down never fails a deploy. In the console, Settings › General › Repository shows whether the App reaches the repository, and New project lists the repositories it can read and which of them have a floor.toml.

Not built yet

  • Building inside Floor. CI or your machine builds everything.
  • Pull-request previews. One server can't run a copy per pull request.

On this page