Builds
A build produces files that other nodes consume: compiled packages, generated code, a schema. It runs either once, exiting when the artifacts are written, or as a watcher that keeps rebuilding them.
const packages = defineBuild({
name: 'packages',
run: dev ? 'pnpm turbo watch build' : 'pnpm turbo run build',
mode: dev ? 'watch' : 'once',
artifacts: ['packages/*/dist'],
ready: dev && { log: /Watching for changes/ },
});A one-shot build is available when it exits 0. A watch build is available when it first emits, which it must declare with ready, as Dependencies and readiness explains.
Artifacts
artifacts declares what a build produces. It is not a cache key — Alzo has no build cache and leans on whatever your repository already uses (Turborepo, Nx, BuildKit), because a second memoisation layer whose failure mode is silently not rebuilding is worse than none. It is how the build graph infers edges: where one node's artifact path falls inside another's build context, buildDependsOn is added for you. alzo plan lists the edges it inferred.
Builds that need running services
Builds may depend on running services. Schema generation needs the database up:
const schema = defineBuild({
name: 'schema',
run: 'pnpm run generate-schema',
dependsOn: [db.available],
artifacts: ['packages/schema/index.js'],
});Modelling builds and services as separate graphs would make this inexpressible.
When a watch build fails
Alzo propagates state and touches nothing. The failing build's output becomes unsatisfied, every transitive dependent is marked degraded — stale dependency, and no process is stopped or restarted. The running service is not stale in any recoverable sense: it holds the newest artifacts that ever built successfully, so restarting it would put it back on the same bytes. The mark clears when the dependent actually picks up the new output, not when the build turns green.
Image platform
Some images have no build for your architecture — SQL Server's 2025-latest is still amd64-only — so platform forces one, on a pulled image as well as a built one:
const mssql = defineService({
name: 'mssql',
ports: { sql: 1433 },
provision: { image: 'mcr.microsoft.com/mssql/server:2025-latest', platform: 'linux/amd64' },
});Private dependencies
A Dockerfile that clones a private repository or installs from a private registry needs a credential that must not reach an image layer:
const api = defineService({
name: 'api',
ports: { http: 3000 },
provision: {
image: {
context: './apps/api',
ssh: true, // RUN --mount=type=ssh git clone …
secrets: { npm_token: secret('NPM_TOKEN') }, // RUN --mount=type=secret,id=npm_token …
},
},
});The committed .npmrc holds ${NPM_TOKEN} — npm and pip both resolve that spelling from the environment, and it is exactly what secret() returns, so the configuration, the file and the redacted log line all read the same string.
ssh, secrets and contexts need a BuildKit session, so an image that declares one of them is built with docker buildx; run docker buildx version to check that prerequisite. ssh: true also needs SSH_AUTH_SOCK. Ordinary image builds stay on the Docker Engine API. Secret values reach BuildKit's secret provider from the inherited environment and never appear in process arguments, plans or retained logs.
Private pulled images use Docker's existing login. Run docker login <registry> once. Alzo resolves inline auth, per-registry credHelpers and the global credsStore from Docker's configuration, and sends the result only in the Docker Engine API's registry authentication header. Credentials never enter alzo.config.ts, a plan, a retained record or telemetry.
Build arguments
buildArgs rejects a Secret at compile time. Multi-stage builds do not hide one: --provenance=mode=max records the build request, so a token consumed only in a builder stage still appears in the attestation. BuildKit lints for this too, but by name — it fires on keys that look sensitive, so ARG TOKEN_X slips through. A type cannot be fooled by naming.
Build arguments for a BuildKit session build are passed as --build-arg NAME=value arguments, never through the Docker CLI's environment, so a value cannot redirect the daemon, a proxy, a credential helper or the SSH agent before the Dockerfile sees it. Build arguments are still non-secret by contract: use secrets for anything that grants access.
Rebuilding on change
A build context alone does not watch anything. To rebuild an image and recreate its container when its sources change, list the paths under provision.image.watch, or use a node-level watch with onChange: 'rebuild' as Lifecycle shows.