def export_base_image(base: ImageBase) -> None: """Export the base image to the filesystem.""" publish = bootstrap.bus() export_name = fs_compliant_name(base.image_name) export_path = Path( local.path(bb_cfg()["container"]["export"].value) / export_name + ".tar") if export_path.exists() and export_path.is_file(): export_path.unlink() publish(ExportImage(base.image_name, str(export_path)))
def delete_base_image(base: ImageBase) -> None: """ Delete the base image for the given image base and the current research tool. Args: base: the image base """ publish = bootstrap.bus() publish(DeleteImage(base.image_name))
def create_base_image(base: ImageBase) -> None: """ Build a base image for the given image base and the current research tool. Args: base: the image base """ with TemporaryDirectory() as tmpdir: publish = bootstrap.bus() image_context = BaseImageCreationContext(base, Path(tmpdir)) _create_base_image_layers(image_context) publish(CreateImage(base.image_name, image_context.layers))
def run_container(image_tag: str, container_name: str, build_dir: tp.Optional[str], args: tp.Sequence[str]) -> None: """ Run a podman container. Args: image_tag: tag of the image to use for the container container_name: name for the spawned container build_dir: benchbuild's build directory args: arguments that get passed to the container's entry point """ publish = bootstrap.bus() publish(RunProjectContainer(image_tag, container_name, build_dir, args))
def create_dev_image(base: ImageBase, research_tool: ResearchTool[tp.Any]) -> None: """ Build a dev image for the given image base and research tool. A dev image is used to build the research tool in the container environment. Args: base: the image base research_tool: the research tool """ with TemporaryDirectory() as tmpdir: publish = bootstrap.bus() image_context = BaseImageCreationContext(base, Path(tmpdir)) _create_dev_image_layers(image_context, research_tool) publish(CreateImage(f"{base.image_name}_dev", image_context.layers))