Browse the docs

Add an environment

Declare an environment once. After that, every merge to main deploys the services that changed. You never run a deploy command.

What happens in the cloud

  1. You declare the environment in putnami.ci.json. It names one channel and the workloads that run there.
  2. putnami cloud env enable makes the platform read that file from your repository at an exact commit. The platform accepts it as a numbered revision.
  3. A merge to main publishes a release set and moves the channel.
  4. The platform finds every environment that follows the channel. It compares the release set with what each environment runs.
  5. It deploys only the workloads whose image, config, migrations or deployment declaration differ.
  6. Each service rolls on its own. The old revision keeps serving until the new revision is ready.

Do it

1. Connect the repository

putnami cloud source connect --repo <owner>/<repo>

2. Declare the environment

Add an envs entry to putnami.ci.json, and a rule that publishes main to the channel:

{
  "rules": [
    { "branches": "main", "publish": ["canary"] }
  ],
  "envs": {
    "prod": {
      "channel": "canary",
      "workloads": [
        { "select": ["apps/web-api", "apps/worker"] }
      ]
    }
  }
}
Field Meaning
channel The channel the environment follows. Without one, the environment deploys only when you ask.
workloads[].select Exact project paths. A workload that no rule selects is not part of the environment.
workloads[].channel Overrides the channel for those workloads. See Not supported yet.

3. Turn on deploy for each workload

In the workload's own putnami.json, enable deploy and the deployment declaration. Use @putnami/typescript for a TypeScript workload.

{
  "options": {
    "@putnami/cloud": { "deploy": { "enabled": true } },
    "@putnami/go": { "deployment": true }
  }
}

The deployment declaration carries the settings of infra/runtime.json and the requirements of the workload (databases, events, storage, secrets, scheduled jobs). It counts only in the workload's own putnami.json, not in putnami.workspace.json.

The workload must also publish a config member: it declares a @putnami/cloud:publish-config namespace.

4. Name where the image goes

The platform publishes your image to its OCI registry. Declare the coordinate in putnami.workspace.json:

{
  "registries": {
    "oci": { "publish": "oci.putnami.dev/<namespace>" }
  }
}

5. Check, then enable

putnami cloud env doctor prod
putnami cloud env enable prod

env doctor reads your files and asks the platform one question. It changes nothing. Each check reads ok, failing, degraded or unknown, and a check that is not ok prints its fix. env enable applies every fix your workspace owns, then prints the checks again. It needs the permission platform.workspace.manage. A second run on the same commit writes nothing.

Env doctor checks lists every check and every step.

Merging a change to envs does not accept it. Until you run env enable, the environment keeps following the revision the platform accepted last. If you move prod from canary to latest, a move of latest deploys nothing to it.

6. Merge

Merge the change. The run on main publishes the release set and moves the channel.

Add a workload that was never deployed

You do not deploy it by hand.

  1. Enable deploy and the deployment declaration in its putnami.json (step 3).
  2. Select it in the workloads of the environment.
  3. Merge, then run putnami cloud env enable <env>.

The platform deploys the workload from the release set that the channel points at now. It creates the service for you. A workload with no deployment declaration and no earlier release is not deployable: the move fails it.

What you see

Where What
putnami cloud env status <env> One line per workload: ok, degraded or failing, and the channel generation.
putnami cloud deploy status <cm_id> One deploy and the state of each workload.
putnami.app, change page, Release tab The release and deploy outcomes.

Not supported yet

Not supported What happens instead
constraints.approval: manual A channel move does not deploy the environment.
Progressive rollouts Only all-at-once is accepted.
Environment variants The platform refuses an environment that declares variants.
Workloads on different channels in one environment The move is recorded as not deployable.

When it fails

You see Cause Fix
env doctor exits 1 A check reads failing. Apply the fix the check prints, or run env enable.
env doctor reads degraded on environment-definition The platform deploys from an older accepted revision of putnami.ci.json. Run putnami cloud env enable <env>.
A merge deploys nothing No environment follows the channel, or every workload already runs these artifacts. Run putnami cloud env status <env>. Compare the channel in putnami.ci.json with the rule that publishes.
The move is recorded not_deployable and no environment of that channel deploys The set has no image or config for a workload the environment declares. Publish that workload, or remove it from workloads.

Next