2121import types
2222from typing import List , Optional
2323
24- import python_on_whales
2524import requests
2625
2726from retry import retry
@@ -288,37 +287,15 @@ def get_source_image(self):
288287 source_archive_path : "source.tar" ,
289288 SOURCE_DOCKERFILE : "Dockerfile" ,
290289 }
291- if self .buildrunner_config .run_config .use_legacy_builder :
292- image = legacy_builder .build_image (
293- temp_dir = self .buildrunner_config .global_config .temp_dir ,
294- inject = inject ,
295- timeout = self .docker_timeout ,
296- docker_registry = self .buildrunner_config .global_config .docker_registry ,
297- nocache = True ,
298- pull = False ,
299- )
300- self ._source_image = image
301- else :
302- # Use buildx builder
303- native_platform = self ._step_runner .multi_platform .get_native_platform ()
304- LOGGER .info (f"Setting platforms to [{ native_platform } ]" )
305- platforms = [native_platform ]
306- built_images_info = (
307- self ._step_runner .multi_platform .build_multiple_images (
308- platforms = platforms ,
309- inject = inject ,
310- cache = False ,
311- pull = False ,
312- build_args = {
313- "BUILDRUNNER_DISTRO" : os .environ .get ("BUILDRUNNER_DISTRO" )
314- },
315- )
316- )
317- if len (built_images_info .built_images ) != 1 :
318- raise BuildRunnerProcessingError (
319- "Failed to build source image. Retrying the build may resolve the issue."
320- )
321- self ._source_image = built_images_info .built_images [0 ].trunc_digest
290+ image = legacy_builder .build_image (
291+ temp_dir = self .buildrunner_config .global_config .temp_dir ,
292+ inject = inject ,
293+ timeout = self .docker_timeout ,
294+ docker_registry = self .buildrunner_config .global_config .docker_registry ,
295+ nocache = True ,
296+ pull = False ,
297+ )
298+ self ._source_image = image
322299
323300 return self ._source_image
324301
@@ -519,16 +496,11 @@ def run(self): # pylint: disable=too-many-statements,too-many-branches,too-many
519496 if self ._source_image :
520497 self .log .write (f"Destroying source image { self ._source_image } \n " )
521498 try :
522- if self .buildrunner_config .run_config .use_legacy_builder :
523- _docker_client .remove_image (
524- self ._source_image ,
525- noprune = False ,
526- force = True ,
527- )
528- else :
529- python_on_whales .docker .image .remove (
530- self ._source_image , prune = True , force = True
531- )
499+ _docker_client .remove_image (
500+ self ._source_image ,
501+ noprune = False ,
502+ force = True ,
503+ )
532504 except ImageNotFound :
533505 self .log .warning (
534506 f"Failed to remove source image { self ._source_image } \n "
@@ -540,16 +512,11 @@ def run(self): # pylint: disable=too-many-statements,too-many-branches,too-many
540512 # reverse the order of the images since child images would likely come after parent images
541513 for _image in self .generated_images [::- 1 ]:
542514 try :
543- if self .buildrunner_config .run_config .use_legacy_builder :
544- _docker_client .remove_image (
545- _image ,
546- noprune = False ,
547- force = True ,
548- )
549- else :
550- python_on_whales .docker .image .remove (
551- _image , prune = True , force = True
552- )
515+ _docker_client .remove_image (
516+ _image ,
517+ noprune = False ,
518+ force = True ,
519+ )
553520 except Exception as _ex : # pylint: disable=broad-except
554521 self .log .write (f"Error removing image { _image } : { str (_ex )} \n " )
555522 else :
0 commit comments