Browse the docs

Your first deploy

In about 20 minutes, one of your projects runs as a service in an environment named prod. From then on, each merge to main deploys it. You never type a deploy command.

What happens in the cloud

  1. You declare how the project runs, in infra/runtime.json, and which environment runs it, in putnami.ci.json.
  2. You merge. The run on main builds the project and publishes it as a release set: the image, the config and the migrations of one commit.
  3. The run moves the channel canary to that release set.
  4. putnami cloud env enable prod makes the platform accept the environment. prod follows canary, so the platform deploys what canary points at.
  5. The platform creates the service, pins its config, and starts it.

Releases, channels and environments explains each idea.

Before you start

  • A repository connected to a workspace.
  • A Go or TypeScript project that serves HTTP and builds with putnami build. This page calls it apps/hello.

1. Declare how the project runs

Add apps/hello/infra/runtime.json. This file makes the project a service:

{
  "ingress": { "domains": ["<your-host>"] },
  "scaling": { "max": 2, "concurrency": 500 }
}
  • ingress.domains: the hosts the service answers on. There is no default address. The platform serves a host only when a certificate covers it. Hosts under putnami.cloud and putnami.dev are covered. Certificates and DNS for your own domain are not self-service yet.
  • scaling.max: at most 2 instances.
  • scaling.concurrency: 500 requests per instance before a second one starts.

Idle services scale to zero. The first request after an idle period waits for an instance to start.

2. Turn on the deploy of the project

In apps/hello/putnami.json, turn on its deploy and its deployment declaration. For a TypeScript project, write @putnami/typescript in place of @putnami/go.

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

In putnami.workspace.json, name where the image goes:

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

3. Declare the environment

In putnami.ci.json, publish main to canary, and declare prod, which follows canary and runs apps/hello:

{
  "rules": [
    { "branches": "main", "publish": ["canary"] }
  ],
  "envs": {
    "prod": {
      "channel": "canary",
      "workloads": [{ "select": ["apps/hello"] }]
    }
  }
}

4. Merge

Open a pull request with these changes and merge it. The run on main publishes apps/hello and moves canary. Nothing deploys yet: the platform does not know prod.

5. Check and enable the environment

putnami cloud env doctor prod
putnami cloud env enable prod
  • env doctor checks each prerequisite and prints the fix of each one that fails. It changes nothing.
  • env enable reads putnami.ci.json at the head of main, applies the fixes your workspace owns, and accepts prod. The platform then deploys apps/hello from the release set canary points at.

env enable needs a workspace admin. A second run on the same commit changes nothing.

What you see

putnami cloud env status prod --health

One line per service: its state (ok, degraded or failing) and the revision it serves.

To follow one deploy, service by service:

putnami cloud env status prod --provenance
putnami cloud deploy status <cm_id>

--provenance prints the deploy id of each service: it starts with cm_. deploy status shows each step, and the step and the reason when it failed.

To read the config the service runs with:

putnami cloud config show --env prod

When it fails

You see Cause Fix
env doctor exits 1 a check fails run the fix the check prints, or env enable
env status shows no service env enable did not run after the merge putnami cloud env enable prod
deploy status shows failed at a migration a migration failed; the old revision, if any, keeps serving fix the migration and merge again
deploy status shows failed at start the service did not become ready read its errors: putnami cloud logs hello --since deploy:last --level error
the host does not answer no certificate covers the host use a host under putnami.cloud or putnami.dev

Change it, roll it back

  • Change it: merge again. The platform deploys only the services whose image, config, migrations or deployment declaration changed. The old revision serves until the new one is ready.

  • Roll it back: point canary at an earlier release set. The environment deploys it like any merge:

    putnami cloud channels set canary --from rs_<previous>

    See roll back.

Next