Skip to content

Commit

Permalink
Merge pull request #63 from shanejbrown/main
Browse files Browse the repository at this point in the history
Pass build args to multiplatform image builds
  • Loading branch information
shanejbrown authored Aug 28, 2023
2 parents 3d52c55 + 1f07fe4 commit 0f88cd6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
17 changes: 12 additions & 5 deletions buildrunner/docker/multiplatform_image_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def _build_single_image(self,
path: str = ".",
file: str = "Dockerfile",
tags: List[str] = None,
docker_registry: str = None,
build_args: dict = None,
built_images: list = None) -> None:
"""
Builds a single image for the given platform
Expand All @@ -236,6 +236,8 @@ def _build_single_image(self,
tags = ["latest"]
if built_images is None:
built_images = []
if build_args is None:
build_args = {}

assert os.path.isdir(path) and os.path.exists(f"{file}"), \
f"Either path {path}({os.path.isdir(path)}) or file " \
Expand All @@ -250,7 +252,7 @@ def _build_single_image(self,
platforms=[platform],
push=push,
file=file,
build_args={'DOCKER_REGISTRY': docker_registry})
build_args=build_args)

# Check that the images were built and in the registry
# Docker search is not currently implemented in python-on-wheels
Expand Down Expand Up @@ -284,7 +286,8 @@ def build_multiple_images(self,
tags: List[str] = None,
push=True,
do_multiprocessing: bool = True,
docker_registry: str = None,) -> List[ImageInfo]:
docker_registry: str = None,
build_args: dict = None) -> List[ImageInfo]:
"""
Builds multiple images for the given platforms. One image will be built for each platform.
Expand All @@ -301,6 +304,10 @@ def build_multiple_images(self,
List[ImageInfo]: The list of intermediate built images, these images are ephemeral
and will be removed when the builder is garbage collected
"""
if build_args is None:
build_args = {}
build_args['DOCKER_REGISTRY'] = docker_registry

LOGGER.debug(f"Building {name}:{tags} for platforms {platforms} from {file}")

if self._use_local_registry and not self._local_registry_is_running:
Expand Down Expand Up @@ -330,7 +337,7 @@ def build_multiple_images(self,
path,
file,
tags,
docker_registry,
build_args,
self._intermediate_built_images[name])))
else:
self._build_single_image(curr_name,
Expand All @@ -339,7 +346,7 @@ def build_multiple_images(self,
path,
file,
tags,
docker_registry,
build_args,
self._intermediate_built_images[name])

for proc in processes:
Expand Down
1 change: 1 addition & 0 deletions buildrunner/steprunner/tasks/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ def run(self, context):
file=self.dockerfile,
name=self.get_unique_build_name(),
docker_registry=docker_registry,
build_args=self.buildargs,
)

assert len(built_images) == len(self.platforms), \
Expand Down

0 comments on commit 0f88cd6

Please sign in to comment.