TheDocumentation Index
Fetch the complete documentation index at: https://docs.compartment.dev/llms.txt
Use this file to discover all available pages before exploring further.
build block in a service config tells Compartment how to turn your source code into a runnable image. You can let Compartment choose automatically, force a specific strategy, provide a custom build command, install extra APT packages, and expose runtime variables at compile time. All build fields are optional — omitting the block entirely is equivalent to setting strategy: auto.
Fields
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
strategy | string | No | auto | Build strategy to use. One of auto, dockerfile, or railpack. |
command | string | No | — | Custom build command. Railpack strategy only. |
env | string[] | No | [] | Variable key names to expose during the build step. |
packages | object | No | — | APT packages to install. Railpack strategy only. |
packages.build | string[] | No | [] | APT packages installed in the build stage. |
packages.runtime | string[] | No | [] | APT packages installed in the runtime stage. |
Build strategies
auto (default)
Compartment inspects your service directory and picks the right tool automatically:
- If a
Dockerfileis present → uses the Dockerfile build. - If no
Dockerfileis present → uses Railpack to detect your framework and build automatically.
strategy at all when using auto detection.
dockerfile
Forces Compartment to use the Dockerfile in your service directory. The build fails if no Dockerfile is present.
railpack
Forces Compartment to use Railpack regardless of whether a Dockerfile exists. Use this when you want to opt into Railpack’s zero-config builds but your repository happens to contain a Dockerfile for a different purpose.
Custom build command
Usecommand to override the build command that Railpack runs. This replaces whatever Railpack would infer from your project’s framework and package manager.
command is only valid for Railpack builds. Setting it alongside strategy: dockerfile is a validation error.Exposing variables during the build
List variable key names underenv to make those variables available to the build process. The values must already be set via compartment variable set or imported before you deploy.
APT packages
Usepackages to install additional APT packages that your build or runtime image needs. This is useful when a native dependency is not bundled by default in the Railpack base images.
packages.build— packages installed during the build stage only. They are not present in the final runtime image.packages.runtime— packages installed in the runtime stage. They are available when your service runs.
., +, :, =, ~, and -.
If you specify packages, at least one of build or runtime must contain at least one entry.
Complete example
Strategy comparison
- auto
- dockerfile
- railpack