hammerkit
Build file

Build file reference

Every key the build-file schema accepts.

This is the complete reference for the hammerkit build file, derived from the schema hammerkit validates against (build.schema.json). Unknown keys are rejected, so this list is exhaustive. For prose and examples, follow the links to the dedicated pages.

Top-level keys

KeyTypeDescription
envsmap of string→string/numberBuild-file-wide environment variables.
tasksmap of name→taskThe tasks in this file.
servicesmap of name→serviceThe services in this file.
referencesmap of prefix→pathReference other build files (keep their own directory).
includesmap of prefix→pathInclude other build files (use this file's directory).
environmentsmap of name→environmentRun targets (Kubernetes or remote Docker).
cachesmap of name→cacheNamed cache declarations (method + backend).
labelsmap of string→string/numberLabels applied to every task/service in the file.

Task

A task is either a container task (it has an image) or a local task (no image). Both share these fields:

FieldTypeDescription
cmdsarray of string | {cmd, path}Commands to run, in order. path sets the working directory for that command.
descriptionstringShown by ls; a missing one is a validate warning.
srcarray of stringInput files/folders/globs used for caching.
generatesarray of string | {path, export, resetOnChange, name}Output paths. export: true copies back to the workspace; resetOnChange: true wipes it before a re-run.
depsarray of stringTasks (name or prefix:name) that run first.
needsarray of string | {service, name}Services that must be ready first.
envsmap of string→string/numberTask-level environment variables (override build-file envs).
labelsmap of string→string/numberLabels for filtering.
cachestring | {name, method}Cache method shorthand or a named cache reference.
extendstringBase task to inherit from (prefix:name).
shellstringShell used to run cmds (default /bin/sh).
continuousbooleanTask watches itself; hammerkit won't restart it in watch mode.
timeoutduration (30s, 10m, 1h30m)Maximum execution time; the task fails when exceeded.

Container task adds:

FieldTypeDescription
imagestring (required)The container image to run in. Its presence is what makes the task containerized.
mountsarray of stringExtra host[:container] mounts.

Local task adds:

FieldTypeDescription
platform{os, arch}Restrict to os (win/macos/linux) and/or arch (arm64/arm).

Service

A service is either a container service (it has an image) or a Kubernetes service (it has a selector).

Container service:

FieldTypeDescription
imagestring (required)The service image.
cmdstringOverride the container command.
portsarray of string/numbercontainerPort or hostPort:containerPort to publish to the host.
healthcheck{cmd}Readiness command; see healthcheck.
envsmap of string→string/numberService environment variables.
volumesarray of stringname:containerPath volumes that persist across restarts.
mountsarray of stringhost:container config mounts.
depsarray of stringTasks that must run before the service starts.
needsarray of string | {service, name}Other services this one depends on.
srcarray of stringSources, used for caching the service image build.
labelsmap of string→string/numberLabels for filtering.
descriptionstringDescription shown by ls.
continuousbooleanLong-running service (the usual case).

Kubernetes service (forwards an existing cluster resource — see Kubernetes service):

FieldTypeDescription
selector{type, name} (required)Resource type (deployment/service/pod) and name to forward.
portsarray of string/number (required)hostPort:containerPort mappings to forward to localhost.
contextstringOverride the environment's kube context.
namespacestringOverride the environment's namespace.
kubeconfigstringOverride the environment's kubeconfig path.
depsarray of stringTasks that run before forwarding.
labels / description–As above.

Cache (caches)

Each named cache has a method and a backend (see caches):

FieldTypeDescription
methodchecksum | modify-date | noneHow changes are detected.
backend.typelocal | s3 | registryWhere results are stored.
backend.pathstring (local)Directory; defaults to ~/.hammerkit/remote-cache.
backend.bucketstring (s3, required)Target bucket.
backend.region / endpoint / prefix / forcePathStyle– (s3)S3 connection options.
backend.repositorystring (registry, required)OCI repository without a tag, e.g. ghcr.io/org/cache.
backend.insecureboolean (registry)Use plain HTTP; defaults to true only for localhost.
retention.maxAge / maxSize / keepPerTaskduration / size / integerRetention policy for cache prune and automatic pruning.

A task's cache field is either the method shorthand (cache: checksum) or a reference {name, method} to a declared cache.

Environment (environments)

Each environment is a run target — exactly one of:

KeyFieldsDescription
kubernetescontext (required), namespace, kubeconfig, ingresses[]Run tasks as jobs and services as deployments on a cluster.
dockerhostRun against a remote Docker daemon.

An ingresses entry has kind (ingress/httproute), host, service, servicePort, path, gateway, gatewayNamespace — see ingresses.

On this page