From 4e66cc2f5982cdab26e3838411a37ea115fd7ef5 Mon Sep 17 00:00:00 2001 From: Michal Nasiadka Date: Thu, 11 Jun 2026 21:47:52 +0100 Subject: kolla-build: Add Docker BuildKit support via docker buildx build Add --buildkit flag to use docker buildx build instead of the docker-py SDK. An optional --buildkit-builder selects a named buildx builder instance, enabling docker-container or remote drivers for multi-arch builds. --buildkit and --squash are mutually exclusive and rejected at startup. PushTask is skipped when buildkit is active; push is handled inline. Set buildkit as the new default. Change-Id: Idbf1d1bdc091bb84721f8006c2b916731b999859 Signed-off-by: Michal Nasiadka --- kolla/common/config.py | 8 ++++++++ kolla/common/utils.py | 15 +++++++++++++++ 2 files changed, 23 insertions(+) (limited to 'kolla/common') diff --git a/kolla/common/config.py b/kolla/common/config.py index c4ebcbf3b..b418552f4 100644 --- a/kolla/common/config.py +++ b/kolla/common/config.py @@ -171,6 +171,14 @@ _CLI_OPTS = [ help='The Docker namespace name'), cfg.StrOpt('network_mode', default='host', help='The network mode for Docker build. Example: host'), + cfg.BoolOpt('buildkit', default=True, + help='Use Docker BuildKit (docker buildx build) when building ' + 'images. Requires the docker-buildx-plugin to be ' + 'installed. Only valid with --engine docker.'), + cfg.StrOpt('buildkit-builder', default=None, + help='Name of the docker buildx builder instance to use. ' + 'If unset the currently active builder is used. ' + 'Only valid with --buildkit.'), cfg.BoolOpt('cache', default=True, help='Use the container engine cache when building'), cfg.StrOpt('patches-path', default=None, diff --git a/kolla/common/utils.py b/kolla/common/utils.py index 4ee80768f..485848ba2 100644 --- a/kolla/common/utils.py +++ b/kolla/common/utils.py @@ -54,6 +54,21 @@ def make_a_logger(conf=None, image_name=None): LOG = make_a_logger() +def check_docker_buildx(): + try: + subprocess.check_output( # nosec + ['docker', 'buildx', 'version'], stderr=subprocess.STDOUT) + except OSError as ex: + if ex.errno == 2: + LOG.error('"docker" command is not found.') + raise + except subprocess.CalledProcessError: + LOG.error('"docker buildx" is not available. ' + 'Install the docker-buildx-plugin or disable BuildKit ' + 'with "--nobuildkit".') + raise + + def get_docker_squash_version(): try: -- cgit v1.2.3