Skip to content

Commit

Permalink
Fix references to docker registry image and fix docs
Browse files Browse the repository at this point in the history
  • Loading branch information
saville committed Nov 8, 2023
1 parent 7998e27 commit 6824d3a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
9 changes: 6 additions & 3 deletions buildrunner/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,9 +582,12 @@ def run(self): # pylint: disable=too-many-statements,too-many-branches,too-many

exit_explanation = None
try: # pylint: disable=too-many-nested-blocks
with MultiplatformImageBuilder(keep_images=not self.cleanup_images,
temp_dir=self.global_config.get_temp_dir(),
disable_multi_platform=self.disable_multi_platform) as multi_platform:
with MultiplatformImageBuilder(
docker_registry=self.global_config.get_docker_registry(),
keep_images=not self.cleanup_images,
temp_dir=self.global_config.get_temp_dir(),
disable_multi_platform=self.disable_multi_platform,
) as multi_platform:
if not os.path.exists(self.build_results_dir):
# create a new results dir
os.mkdir(self.build_results_dir)
Expand Down
14 changes: 8 additions & 6 deletions buildrunner/docker/multiplatform_image_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from platform import machine, system
import shutil
import tempfile
from typing import List
from typing import List, Optional

import python_on_whales
from python_on_whales import docker
Expand Down Expand Up @@ -117,12 +117,16 @@ def __repr__(self):
class MultiplatformImageBuilder: # pylint: disable=too-many-instance-attributes
"""Multiple platform image builder"""

# pylint: disable=too-many-arguments
def __init__(
self,
docker_registry: Optional[str] = None,
use_local_registry: bool = True,
keep_images: bool = False,
temp_dir: str = os.getcwd(),
disable_multi_platform: bool = False,):
disable_multi_platform: bool = False,
):
self._docker_registry = docker_registry
self._registry_info = None
self._use_local_registry = use_local_registry
self._keep_images = keep_images
Expand Down Expand Up @@ -193,7 +197,7 @@ def _start_local_registry(self):
"""
if not self._local_registry_is_running:
logger.debug("Starting local docker registry")
container = docker.run("registry", detach=True, publish_all=True)
container = docker.run(f"{self._docker_registry}/registry", detach=True, publish_all=True)
ports = container.network_settings.ports

# If any assert fails something changed in the registry image and we need to update this code
Expand Down Expand Up @@ -379,7 +383,6 @@ def build_multiple_images(
tags: List[str] = None,
push=True,
do_multiprocessing: bool = True,
docker_registry: str = None,
build_args: dict = None,
inject: dict = None,
) -> List[ImageInfo]:
Expand All @@ -394,7 +397,6 @@ def build_multiple_images(
tags (List[str], optional): The tags to apply to the image. Defaults to None.
push (bool, optional): Whether to push the image to the registry. Defaults to True.
do_multiprocessing (bool, optional): Whether to use multiprocessing to build the images. Defaults to True.
docker_registry (str, optional): The docker registry to push the image to. Defaults to None.
build_args (dict, optional): The build args to pass to docker. Defaults to None.
inject (dict, optional): The files to inject into the build context. Defaults to None.
Expand All @@ -409,7 +411,7 @@ def get_path(file):

if build_args is None:
build_args = {}
build_args['DOCKER_REGISTRY'] = docker_registry
build_args['DOCKER_REGISTRY'] = self._docker_registry

# It is not valid to pass None for the path when building multi-platform images
if not path:
Expand Down

0 comments on commit 6824d3a

Please sign in to comment.