Skip to content

Concepts

Environments

Every run belongs to an environment. Each environment has its own current deployment, variables and API keys, so dev, staging, prod and each branch run side by side.

On this page

Every project has its own set of these environments, so two apps never share a deployment, a key or a queue.

The environments#

EnvironmentWhat it is for
devDevelopment. A local serve makes its code current here by default.
stagingTesting before production. Previews inherit its variables.
prodProduction.
preview/<branch>One per git branch, created by the branch's first deploy.

dev, staging and prod always exist and can never be archived.

What an environment holds#

  • A current deployment. A run triggered in the environment runs that deployment's code. One deployment can be current in several environments at once.
  • Variables, encrypted, that its runs receive as environment variables.
  • API keys. A key belongs to one environment, and every run it starts lands there.
  • Its runs, and their idempotency keys. The same key in dev and prod names two runs.

Runs keep their deployment#

A run is pinned to the deployment that was current when it was accepted. Its retries, its workflow steps and its children all run that same code, even after a newer deployment becomes current. New code reaches new runs only.

That makes a deploy safe while workflows wait. A workflow sleeping for a week wakes up on the code it started with, so its replay always matches.

Make a deployment current#

A deployment is a registered, content-addressed build of your code (Deploying). Make one current with a deploy, or promote an existing one:

Terminal
durable-compute deploy --manifest manifest.json --env stagingdurable-compute environments promote prod --deployment <deployment id>

Promoting to prod exactly what you tested on staging needs no rebuild: the deployment ID names the same images.

Previews#

Deploy a branch to its own environment:

Terminal
durable-compute deploy --manifest manifest.json --env preview --branch kirby/login

That creates preview/kirby/login, or reuses it, and makes the build current there. A branch name is 1 to 100 bytes of /-separated segments made of letters, digits, ., _ and -. No segment may start with . or -, and .. is not allowed.

  • A preview uses staging's variables, unless it sets its own value for a name.
  • Previews never get warm workers. They run a declared schedule only when it names preview, and archiving a preview removes its schedules.
  • Archive a preview when the branch is merged. It then refuses new runs and deploys, while runs already accepted finish and its history stays readable. environments unarchive brings it back.
Terminal
durable-compute environments archive preview/kirby/login

A local server and its environment#

durable-compute serve makes its deployment current in dev, or in the environment --env names. It does so only when the environment has no current deployment, or when a server start set the current one. Restarting serve after an edit therefore runs the new code, and a restart never undoes a promotion. serve --promote makes its deployment current anyway.