A melange build file is a YAML document that fully describes how to fetch, compile, and package software into an APK. Every build file must declare at minimum aDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/chainguard-dev/melange/llms.txt
Use this file to discover all available pages before exploring further.
package section with metadata, an environment section describing the build environment, and a pipeline section containing the ordered steps that produce the final package. Optional sections such as subpackages, vars, var-transforms, data, options, and update extend this baseline to support complex, multi-output builds and automated version tracking.
Top-level sections
| Section | Required | Purpose |
|---|---|---|
package | ✅ Yes | Package identity, version, copyright, and runtime dependencies |
environment | ✅ Yes | Build environment: repositories, packages, and env vars |
pipeline | ✅ Yes | Ordered steps that produce the package |
subpackages | No | Additional APK outputs from the same build |
vars | No | Custom template variables available across the pipeline |
var-transforms | No | Regex-based transformations of existing variables |
data | No | Arbitrary lists for generating multiple subpackages via range |
update | No | Configuration for automated version tracking |
options | No | Named deviations to the default build (e.g. swappable backends) |
package
The package section defines the identity and metadata of the APK being produced. The combination of name, version, and epoch forms the APK filename: <name>-<version>-r<epoch>.apk.
Unique name for the package. By convention this matches the YAML filename without the extension and aligns with how the package is named in other distributions.
Upstream version of the package. This must be a valid APK version string — avoid characters such as
+ that have special meaning in APK (see var-transforms for how to handle non-standard upstream version strings).Monotonically increasing integer (starting at
0) that distinguishes successive builds of the same upstream version — for example, when backporting a security patch without bumping the upstream version.Human-readable description of the package. This text appears in
apk search and apk info output.URL to the package’s upstream homepage.
Git commit hash of the package build configuration, used for tracking purposes.
List of CPU architectures to build for. Valid values:
386, amd64, arm/v6, arm/v7, arm64, ppc64le, s390x, x86_64, aarch64, or the special value all. Defaults to all when omitted.List of copyright entries for the package. Each entry can specify a
license (SPDX identifier), optional paths (file globs), an attestation (free-form copyright text), and a license-path pointing to the on-disk license file.Runtime and virtual-package dependency declarations.
runtime— packages required at install time (not build time)provides— virtual package aliases this package satisfiesreplaces— packages that this package supersedesprovider-priority— integer string used to break ties when multiple packages provide the same virtual packagereplaces-priority— integer string used to break ties when multiple packages declare the samereplacestarget
SCA (Static Content Analysis) behaviour flags. All default to
false.no-provides— virtual package that ships no files or librariesno-depends— self-contained package with no runtime dependenciesno-commands— suppress scanning/usr/binfor command providersno-versioned-shlib-deps— do not generate versioned shared-library dependencies
Scripts executed during APK lifecycle events:
pre-install, post-install, pre-deinstall, post-deinstall, pre-upgrade, and post-upgrade. Each script must include a shebang line.Maximum build duration in seconds. Useful for catching runaway builds.
Resource hints for external schedulers and the QEMU runner. Fields:
cpu (string), memory (Kubernetes quantity, e.g. "16Gi"), disk, cpumodel.environment
The environment section specifies the build environment: which package repositories to use, which packages to install as build-time dependencies, and which environment variables to set. See Configuring the Build Environment for full details.
The
environment block can only be defined at the top level. Subpackage build definitions cannot override it — though subpackage test definitions can specify their own environment.pipeline
The pipeline section is an ordered list of steps that fetch sources, compile code, and install files into the staging directory. Each step can reference a built-in pipeline (uses:), run a shell command (runs:), or embed a sub-pipeline (pipeline:).
if: conditionals to gate execution based on build context:
subpackages
The optional subpackages section lists additional APK outputs produced by the same build. Each subpackage has its own name, description, pipeline, and dependencies. Subpackages can also carry if: conditionals:
vars
The vars section defines a map of arbitrary string variables that can be referenced anywhere in the build file using ${{vars.<name>}} substitution syntax.
var-transforms
The var-transforms section applies regular-expression transformations to existing variables, creating new derived variables. This is particularly useful for normalising upstream version strings that are incompatible with APK’s version format. See Variable Transformations for full details.
data
The data section provides named lists of key-value pairs that can be iterated over using range: in subpackages or pipeline steps to generate multiple outputs from a single template.
update
The update section declares how automated tooling can discover and apply new upstream versions. Supported monitors include github:, release-monitor:, git:, and oci:.
options
Named build option blocks that override vars or environment packages when activated via --build-option at the command line. See Build Options for full details.
Complete example: gnu-hello.yaml
The following is the complete, workinggnu-hello.yaml example from the melange repository. It demonstrates the three required sections (package, environment, pipeline) together with copyright metadata and the fetch, autoconf/*, and strip built-in pipeline steps.
packages/ directory organised by architecture.