For a while, I built my UBI images by chaining Dockerfiles. Each tool had its own recipe, and a script passed the result of one build to the next. Running make build gave me a CI-ready image with all the tools installed in the order I had chosen.
The system worked. When I wanted recipes to declare their own dependencies and share common ones, I tried Dev Container Features. I eventually moved the image composition to CEKit and published the result as CEKit UBI Modules.
The examples of the previous system are simplified and use fictional names and tags.
How I used to compose the images
The repository that assembled the image pulled in tool recipes as Git submodules. Each piece had a Dockerfile and a Makefile. The Dockerfile accepted SOURCE_IMAGE as a build argument and used it in FROM.
ARG SOURCE_IMAGE
FROM ${SOURCE_IMAGE}
RUN microdnf install -y jq && microdnf clean all
That meant I could use the same Dockerfile on its usual base or on an intermediate image that already contained other tools. Each Makefile essentially ran the following command.
buildah build --layers \
--build-arg "SOURCE_IMAGE=$SOURCE_IMAGE" \
--tag "$LOCAL_IMAGE" .
The composition lived in build.sh. The script loaded each component’s settings, passed the previous image to the Makefile as SOURCE_IMAGE, and gave the result a local tag. That tag became the input to the next build. The first piece could be a prebuilt image. Each subsequent piece built on top of it in turn.
For example, I could start from a UBI image with additional package repositories, add container build tools, then image inspection tools, and finally CI utilities. The order was visible in the script and could be changed without editing each tool’s Dockerfile.
Where the diamond appears
The chain works well when whoever writes build.sh knows all the pieces and controls their order. The problem changes when each piece starts declaring its own dependencies. Imagine an image that needs Git and Python, with both tools requiring the same startup machinery.
- Working image → Git → Shared startup
- Working image → Python → Shared startup
With the previous system, I could resolve that by hand. I put the shared startup component first, then Git, then Python, passing each build result to the next FROM. That turned the diamond into a valid sequence. If a dependency changed, I had to update the list for the image that consumed it.
A parameterized FROM already gave me a way to compose images. I wanted the recipes to express their dependencies so that the builder could derive the order and install shared components once.
What I tried with Dev Container Features
I tried packaging the pieces as Features. I split the trusted certificate, the startup machinery, and Python into separate pieces. In that prototype, Python declared dependencies on the other two Features. I built an intermediate image with the Dev Containers CLI and Podman, then used it as the base for another Buildah build.
The first command assumes a prepared .devcontainer/devcontainer.json. The second assumes a final Dockerfile with ARG BASE_IMAGE and FROM ${BASE_IMAGE}.
devcontainer build --workspace-folder . \
--docker-path podman --buildkit never \
--image-name localhost/demo/ubi-features:local
buildah build \
--build-arg BASE_IMAGE=localhost/demo/ubi-features:local \
--tag localhost/demo/ubi-final:local .
Features resolve dependencies transitively. With dependsOn, each branch can request a dependency and supply options. The specification treats requests for the same Feature with different options as distinct. installsAfter only orders Features that are already scheduled for installation. In a diamond where the shared component needs a single configuration, you still have to decide what options both branches receive and where to set them. Dev Container Features specification.
The prototype also had its own build, test, packaging, and publishing workflow for Features. My day-to-day goal was still to build UBI images for different uses, so I looked for a way to declare the contents of each image directly and inspect the resulting Containerfile.
The final composition with CEKit
With CEKit, each component has a module.yaml and the scripts or files it needs. The image declares its base and the modules to install. Buildah still builds the image from the context CEKit generates.
The Git and Python diamond can be reproduced with the modules in the public project. Both depend on entrypoint because both can supply hooks that run when the container starts. CEKit reaches entrypoint through two paths and includes it once.
Save this image.yaml in an empty test directory. It uses the public repository as its module catalog.
schema_version: 1
name: localhost/demo/ubi-tools
version: local
from: docker.io/redhat/ubi10-minimal:latest
modules:
repositories:
- git:
url: https://github.com/guillermomolina/cekit-ubi-modules.git
ref: main
install:
- name: git
- name: python
run:
cmd: ["/bin/sh"]
With Python 3.12 or later, Git, Buildah, and Podman installed, you can generate and inspect the Containerfile, then build the image and check that both tools run.
python3 -m venv .venv
. .venv/bin/activate
python -m pip install 'cekit==4.16.0'
cekit build --dry-run buildah
find target -name Containerfile -print
cekit build buildah --tag localhost/demo/ubi-tools:local --no-squash
podman run --rm localhost/demo/ubi-tools:local \
/bin/sh -c 'git --version && python3 --version'
The --dry-run lets you inspect installer order and check that the entrypoint installer appears once. The last command checks the result at runtime. The repository also includes examples and a make check target that checks shell syntax and generates the example Containerfiles. To pin the module selection in CI, replace ref: main with a reviewed commit.
One migration decision was to remove the custom CA dependency from Python. There is now an optional CA module, and the image that needs it supplies its own certificate. Each consumer also supplies its own service configuration, and credentials are provided at runtime. This lets the public catalog work with a standard UBI base.
I still use FROM and Buildah. What changed is what I write when I need a new variant. I used to order a chain of builds and pass tags between them. Now I declare the base and modules in image.yaml, and their dependencies determine what gets installed and in what order.