Skip to content
agents start at /llms.txtthis page as markdown /docs/deploy.md
smallrun

Deploy

How smallrun deploy works, what it prints, the deployment states, and what rollback does.

One command uploads the source, builds it and starts the app.

Command

sh
export SMALLRUN_TOKEN=<token>
smallrun deploy --json
  • The command blocks until the deployment is RUNNING or FAILED.
  • On success it prints the URL: https://<app>.smallrun.org.
  • On failure it prints the last log lines of the phase that failed.
  • With --json, the command returns one JSON object.

Authentication

Who How
An agent or a script The SMALLRUN_TOKEN environment variable. The token belongs to one account and can be revoked. The app is owned by that account
A person at a terminal smallrun login

What is uploaded

  • Everything in the app's folder, including .env, except .git.
  • .smallrunignore leaves more out, one pattern per line: node_modules/ (a folder anywhere), /logs (from the app's folder), *.zip (a name anywhere). Lines starting with # are comments.
  • The upload is at most 100 MB compressed.

What happens

  1. The CLI uploads the source as a tarball.
  2. The language and its version line are detected, for example php@8.3, with the install, build and start commands and any workers.
  3. A throwaway build microVM starts with the platform's runtime image for that line and builds the app. If no app has used that line yet, the platform builds the image first, so that deploy takes longer. The app's code and dependencies become the deployment image.
  4. The app starts in its own microVM and the health check is called.
  5. The app's hostname is routed to the new deployment.

Supported with no configuration: Go, Rust, PHP, .NET, Python, Node.

The first build of a compiled language (Go, Rust, .NET) is slow. Later builds reuse a cache.

Runtime updates

  • The runtime (PHP, Node, Python, .NET) is a runtime image kept by the platform. The app is tied to a line, such as php@8.3, not to a patch.
  • Patch releases, for example a security fix from 8.3.0 to 8.3.1, are applied by the platform with no rebuild: a sleeping app wakes on the new patch, an awake app restarts on it at its next idle moment. If the health check fails, the app goes back to the previous patch.
  • Moving to another line, such as php@8.4, is a change of runtime: in the manifest and a deploy.
  • Go and Rust apps are one binary. After a toolchain fix, smallrun deploy --rebuild rebuilds the current deployment from its stored source.

Deployment states

text
PENDING → BUILDING → BUILT → DEPLOYING → STARTING → RUNNING
                                                       ↓
                                              SUPERSEDED | STOPPED
Any phase → FAILED
State Meaning
RUNNING The app serves requests
FAILED A phase failed. The output names the phase and points to its log
SUPERSEDED A newer deployment replaced this one
STOPPED The deployment was stopped

An app has its own state, separate from its deployments: ACTIVE, SLEEPING or STOPPED.

Rollback

sh
smallrun rollback --json
  • Rollback points the app at an earlier deployment.
  • Rollback does not revert data. The volume and the database stay as they are.
  • A snapshot of the volume is taken before every deploy. Data is restored separately.

Errors

Every error carries three things:

  • A stable code
  • A message
  • A suggested next action

The list of error codes is not published yet.