A service in Compartment is the smallest deployable unit — one process, one container, one entry in yourDocumentation 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.yml. Every project contains at least one service, and most production applications define several: a frontend, an API, a background worker, and so on. Each service has its own build pipeline, runtime configuration, readiness check, and deployment lifecycle, all scoped to the project it belongs to.
Service names
Service names identify a service within a project and must match the pattern^[a-z0-9][a-z0-9_-]{0,62}$, which means:
- starts with a lowercase letter or digit
- contains only lowercase letters, digits, underscores, and hyphens
- is at most 63 characters long
compartment.yml
Service kinds
Thekind field tells Compartment what type of process this service is and how to treat it at runtime. When omitted, the kind defaults to web.
| Kind | HTTP routable | Description |
|---|---|---|
web | yes | A user-facing application served over HTTP. Gets a public or authenticated route URL. |
api | yes | A backend API served over HTTP. Gets a route URL, typically accessed by other services or the CLI. |
worker | no | A long-running background process. No route URL is assigned. |
job | no | A one-shot task that runs to completion. No route URL. |
cron | no | A scheduled task driven by a time expression. No route URL. |
web and api are the only routable kinds. Compartment assigns a routeUrl only to deployments of these two kinds.Shorthand vs. full config
You can declare a service in two forms. The shorthand form accepts a bare path string and inherits all defaults. The full config form lets you override every option.Path
Thepath field is required in full config form. It points to the directory within the repository that contains the service’s source code, relative to the repository root. Compartment uses this directory as the build context.
compartment.yml
Build config
Thebuild block tells Compartment how to compile or package the service. When omitted, Compartment applies its default build strategy automatically.
compartment.yml
Run config
Therun block controls how the built container starts. It supports a custom start command and a restart policy.
compartment.yml
run.command is only supported when the service build resolves to Railpack. If you use build.strategy: dockerfile, omit run.command and define the entrypoint in your Dockerfile instead.Readiness config
Thereadiness block defines how Compartment determines that a newly deployed service is healthy before routing traffic to it. This is the mechanism that enables zero-downtime deployments.
compartment.yml
checking_readiness promotion stage, Compartment polls the configured endpoint until it responds successfully or the timeout expires. If the check passes, the deployment advances to switching_route and takes over live traffic. If it fails, the deployment is marked unhealthy and the previous active deployment continues serving traffic.
Access mode
TheaccessMode field applies to routable services (web and api) and controls whether the route URL requires authentication.
| Value | Behavior |
|---|---|
public | The route URL is accessible without authentication. |
authenticated | The route URL requires a valid session. This is the default. |
compartment.yml
Multi-service example
The following example, drawn from the Compartment multi-service sample, shows two routable services in a single project, each with its own path and readiness probe:compartment.yml
Next steps
Projects
Understand how projects group services and link to your repository.
Deployments
Follow the full lifecycle of a service deployment from build to live traffic.
Service kinds reference
Detailed reference for all service kind behaviors and constraints.
Build options
Full reference for build strategies, packages, and environment variable injection.