Guides

Environments

An environment is an isolated copy of a project's services. Promoting between environments ships the exact bytes you tested, without rebuilding.

What an environment isolates

Every project starts with production. Adding staging gives you a second, fully separate set of:

  • apps, each with their own scaling and domains,
  • environment variables and shared variables,
  • databases, buckets, volumes and jobs.

Nothing is shared implicitly. A staging app cannot reach a production database, and neither can see the other’s variables.

Creating one

In the console, open the project and add an environment. Environment slugs are up to 32 characters and unique within their project, so two projects can each have their own staging.

Keep the slug short

The workspace, project and environment slugs are combined and capped at 63 characters in total. staging is fine; staging-environment-for-integration-testing will push you over the limit once the workspace and project names are added.

Promoting a release

Promotion is the point of having environments. It takes a deploy that is already proven in one environment and releases that identical image into another — no rebuild, so there is no chance of picking up a different dependency version or a changed base image between test and production.

1

Find the deploy you want to promote

bash
$ codaracloud deploys list my-api --env staging
2

Promote it

bash
$ codaracloud promote my-api \    --from-deploy <deploy-id> \    --from-env staging \    --to-env production
3

Confirm it is live

bash
$ codaracloud deploys list my-api --env production

The target environment keeps everything that makes it itself — its own variables, its own database connections, its own domains and replica count. Only the image changes.

The app must already exist in the target

Promotion updates an existing app; it does not create one. Set the app up in the target environment first, then promote into it.

A workable branching setup

Two common shapes, both of which Codara supports directly:

Branch per environment

Point staging at the develop branch and production at main. Each environment builds its own branch on push. Simple, and the branch name tells you what is deployed where — but production builds code that has never been built before, so the two images are never bit-identical.

Build once, promote

Point only staging at a branch. Nothing builds in production; releases arrive by promotion. This is the safer shape: what you tested is literally what ships. Turn off automatic deploys on the production app so it can only change by promotion.

bash
$ codaracloud apps update my-api --env production --manual-deploys

Preview environments

A project can opt in to creating an environment automatically for each pull request, so reviewers get a running copy of the change. Enable it per project:

bash
$ codaracloud projects update website \    --client my-workspace \    --automatic-previews \    --preview-source production

The preview source is the persistent environment whose configuration is copied into each new preview. Previews are marked as such and are meant to be disposable.

Previews use real capacity

Each preview environment runs real containers and real databases, and shares your organization’s plan capacity and storage. Your plan also caps previews per project; past the limit, automatic pull-request previews are skipped, and creating one yourself is refused with 402 plan_limit_exceeded. See Plans and capacity.

Pausing an environment

An environment can be paused as a unit. Apps and dedicated databases stop using compute, scheduled jobs are suspended, and new one-shot jobs wait until resume. Persistent volumes and shared database pools remain, so pausing reduces compute cost but does not make the environment free. Shared database tenants cannot stop their pooled server independently. Resuming restores the environment’s workloads. Pausing a project’s default production environment requires a second confirmation containing its exact slug.

Deleting an environment

A persistent environment must be empty before it can be deleted: remove its apps, databases, jobs, and buckets first. A pull-request preview is different; its deletion performs retry-safe cleanup of the preview’s apps, databases and jobs after an explicit cascade confirmation. Buckets are never cascade-deleted because they may hold customer data, so they must be removed explicitly first. A project’s default environment cannot be deleted until a different environment is marked as default.

Deleting is not reversible

There is no undo and no grace period for resources you remove while emptying an environment or for a preview cascade. Take a backup of anything you might want later before deleting it — see Databases.

Last updated