An environment in Compartment is a named deployment target that gives each stage of your release process — production, staging, preview, and so on — its own isolated set of deployments and variables. When you runDocumentation Index
Fetch the complete documentation index at: https://docs.compartment.dev/llms.txt
Use this file to discover all available pages before exploring further.
compartment deploy, Compartment creates or updates deployments inside the target environment without touching any other environment. Every project starts with a production environment, and you can create as many additional environments as your workflow requires.
Environment names
Environment names are between 1 and 63 characters long with no additional pattern restriction. By convention, use short, lowercase, hyphenated names that reflect the stage’s purpose:productionstagingpreview-feature-xqa
The default environment name is
production. If you omit --env from any CLI command that accepts one, Compartment targets production.Deploying to an environment
Pass--env to compartment deploy to target a specific environment:
What environments isolate
Each environment maintains its own independent state:- Deployments — builds and running containers are never shared across environments. A deployment in
staginghas no impact onproduction. - Variables — values set with
compartment variable setare scoped to an environment. ADATABASE_URLinstagingis a different value from the same variable inproduction. - Active routes — the live URL for a service in
stagingis separate from its URL inproduction.
staging, roll back in one environment, or promote a specific deployment without affecting any other environment.
Managing variables
Variables are set per environment and optionally scoped further to a specific service within that environment.Checking environment status
Usecompartment status to inspect the active deployments and their health in a given environment:
Promoting across environments
A common workflow is to validate a build instaging before promoting it to production. Compartment supports this with compartment promote:
compartment promote to advance a candidate deployment to active within the same environment without rebuilding.
Compartment does not currently support cross-environment promotion of a specific container image. To promote work from
staging to production, re-run compartment deploy targeting production from the same Git commit.Multiple environments in practice
A typical team setup uses three environments:staging
Developers deploy feature branches here for integration testing. Variables point to a staging database and third-party sandbox accounts.
production
The live environment serving real users. Variables point to production infrastructure. Deployments are promoted only after
staging validation passes.Variable scoping rules
When Compartment resolves a variable for a running service, it applies the following priority order — more specific scopes win:- Service-scoped variable for the specific service in the specific environment — highest priority
- Environment-scoped variable for the environment, applied to all services
- A missing variable causes a runtime error if the service expects it
Next steps
Deployments
Learn how Compartment builds, promotes, and routes deployments inside an environment.
Variables reference
Full reference for managing plain and secret variables across environments and services.
Promote and rollback guide
Step-by-step guide to promoting candidates and rolling back to a previous deployment.
Projects
Understand how projects relate to environments and the overall project structure.