Skip to content

imglife build

imglife build [flags]

For each image in build.images, imglife:

  1. Renders Dockerfile.tmpl with the image variables.
  2. Injects OCI labels (build date, git revision, base image reference).
  3. Calls docker build (or docker buildx build for multi-arch).
  4. Pushes the image to the configured registry.
  5. Runs post_image_build hooks.
FlagDefaultDescription
--dry-runfalseRender Dockerfiles without building or pushing
--listfalsePrint what would be built and exit
--output-dir stringWrite build contexts to a directory instead of building
Terminal window
# Build all configured images
imglife build
# Preview — show which images would be built
imglife build --list
# Dry-run — render Dockerfiles, skip docker build
imglife build --dry-run
# Write build contexts for external builder (Kaniko, Buildah)
imglife build --output-dir /tmp/build-contexts

When --output-dir is set, imglife writes one subdirectory per image instead of building:

/tmp/build-contexts/
alpine/
Dockerfile # rendered from template
build.json # build manifest (tag, platforms, etc.)
golang/
Dockerfile
build.json

The build.json manifest contains:

{
"tag": "registry.example.com/bases/alpine:3.21.3-core1.0.0",
"platforms": ["linux/amd64", "linux/arm64"],
"labels": { "org.opencontainers.image.created": "..." }
}

This mode is designed for CI environments using rootless builders like Kaniko or Buildah that require the build context as files. See Base Images — GitLab CI for a complete example.

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

build:
platforms: [linux/amd64, linux/arm64]
builder: imglife-builder

Set up the builder:

Terminal window
docker buildx create \
--name imglife-builder \
--driver docker-container \
--bootstrap

imglife passes these as --label flags to docker build, populating the image’s config.Labels. When a buildx builder is configured (build.builder), the same values are also set as OCI manifest annotations via --annotation, making them visible with docker buildx imagetools inspect. For multi-platform builds, annotations are additionally set at the image-index level.

Label / AnnotationValueCondition
org.opencontainers.image.versionProduced image versionalways
org.opencontainers.image.base.nameFull mirror image referencealways
org.opencontainers.image.createdBuild timestamp (RFC 3339)always
imglife.typeImage type (core, spe, …)always
imglife.core-versionbuild.core_version valuealways
org.opencontainers.image.base.digestMirror image SHA256 digestif resolvable
imglife.platformsTarget platforms (linux/amd64,…)if configured
org.opencontainers.image.revision$IMGLIFE_REVISION env varif env var set
org.opencontainers.image.source$IMGLIFE_SOURCE env varif env var set
org.opencontainers.image.url$IMGLIFE_URL env varif env var set

These labels are consumed by imglife register to auto-detect the base image and platforms.

Set the optional variables in your CI job to populate the traceability labels:

# GitLab CI — build-bases job
variables:
IMGLIFE_REVISION: $CI_COMMIT_SHA # → org.opencontainers.image.revision
IMGLIFE_SOURCE: $CI_PROJECT_URL # → org.opencontainers.image.source
IMGLIFE_URL: $CI_PROJECT_URL/container_registry # → org.opencontainers.image.url

After each run (not in --list mode), imglife prints a summary to stdout:

Build Summary · 12.1s
───────────────────────────────────
Base images in config 4
├─ Built 2
├─ Already exists 2
└─ Errors 0

In --dry-run mode the header is prefixed with [dry-run]. Set NO_COLOR=1 or TERM=dumb to disable ANSI colors.

CodeMeaning
0All images built and pushed successfully
1One or more builds failed