Skip to content

build

The build section defines how imglife generates Dockerfiles from templates and pushes base images to your registry.

build:
core_version: "1.0.0"
registry: registry.example.com/bases
builder: imglife-builder # optional buildx builder name
platforms: [linux/amd64, linux/arm64]
sbom: true
tag_format: "{{.Version}}-core{{.CoreVersion}}"
hooks:
post_image_build:
- cmd: cosign sign --yes {{.Image}}
timeout: 120s
images:
- name: alpine
folder: images/alpine
type: core
mirror_image: registry.example.com/mirrors/alpine
mirror_tag: "3.21.3"
version: "3.21.3"
FieldTypeRequiredDefaultDescription
core_versionstringyesOrganisation build version; bumped when your templates/config change
registrystringyesBase path where built images are pushed
builderstringnodocker buildx builder instance name; omit to use the default
platforms[]stringno[linux/amd64]Default target platforms
sbomboolnofalseAttach SBOM attestation (requires buildx)
tag_formatstringno{{.Version}}-core{{.CoreVersion}}Go template for the image tag
hooks.post_image_build[]HooknoCommands to run after each image is built and pushed
FieldTypeRequiredDefaultDescription
namestringyesImage name (appended to registry)
folderstringyesRelative path to the directory containing Dockerfile.tmpl
typestringyescore, spe, or spe-dev (affects EOL checking)
mirror_imagestringyesMirror image to use as FROM
mirror_tagstringyesSpecific mirror tag to use
versionstringyesVersion encoded in the image tag
tmplstringnoDockerfile.tmplTemplate filename inside folder
argsmap[string]stringnoAdditional --build-arg values
platforms[]stringnoinherits top-levelPer-image platform override
sbomboolnoinherits top-levelPer-image SBOM override
hooksHooksnoPer-image hooks
TypeDescriptionEOL checkedAppears in status
coreProduction base imageYesYes
speSpecial-purpose variantYesYes
spe-devDevelopment variantNoNo

imglife renders Dockerfile.tmpl using Go’s text/template engine. The following variables are available:

VariableExampleDescription
{{.MirrorImage}}registry.example.com/mirrors/alpineMirror image reference (no tag)
{{.MirrorTag}}3.21.3Mirror tag
{{.FQMI}}registry.example.com/mirrors/alpine:3.21.3Fully-qualified mirror image
{{.Version}}3.21.3Image version
{{.CoreVersion}}1.0.0Organisation core version
{{.Name}}alpineImage name
{{.Tag}}3.21.3-core1.0.0Full computed tag

Example Dockerfile.tmpl:

ARG MIRROR_IMAGE={{.FQMI}}
FROM ${MIRROR_IMAGE}
RUN apk add --no-cache \
ca-certificates \
tzdata \
curl
# OCI labels are injected automatically by imglife

imglife injects these OCI labels on every build:

org.opencontainers.image.created = <build timestamp>
org.opencontainers.image.revision = <git SHA>
org.opencontainers.image.source = <project URL>
org.opencontainers.image.base.name = <mirror image>
org.opencontainers.image.base.digest = <mirror digest>

The default tag format is {{.Version}}-core{{.CoreVersion}}. You can customise it:

build:
tag_format: "{{.Version}}-org{{.CoreVersion}}"
# Produces: alpine:3.21.3-org1.0.0

Available template variables: .Version, .CoreVersion, .Name.

build:
platforms: [linux/amd64, linux/arm64]
builder: imglife-builder # buildx builder must support multi-arch

When platforms has more than one entry, imglife uses docker buildx build with --push to publish a multi-arch manifest. A builder with docker-container driver is required.

Instead of building and pushing, imglife can write Docker build contexts to a local directory for consumption by external builders (Kaniko, Buildah):

Terminal window
imglife build --output-dir /tmp/imglife-contexts

Each context directory contains a Dockerfile, a build.json manifest, and any required files. See imglife build for the full reference.

build:
hooks:
post_image_build:
- cmd: cosign sign --yes {{.Image}}
env:
COSIGN_EXPERIMENTAL: "1"
timeout: 120s
continue_on_error: false

In hook commands, {{.Image}} is replaced with the fully-qualified image reference including tag.

Available variables: {{.Image}}, {{.Name}}, {{.Tag}}, {{.Registry}}.