openhands.runtime.utils.runtime_build
BuildFromImageType Objects
class BuildFromImageType(Enum)
SCRATCH
Slowest: Build from base image (no dependencies are reused)
VERSIONED
Medium speed: Reuse the most recent image with the same base image & OH version (a lot of dependencies are already installed)
LOCK
Fastest: Reuse the most recent image with the exact SAME dependencies (lock files)
get_runtime_image_repo_and_tag
def get_runtime_image_repo_and_tag(base_image: str) -> tuple[str, str]
Retrieves the Docker repo and tag associated with the Docker image.
Arguments:
- base_image (str): The name of the base Docker image
Returns:
- tuple[str, str]: The Docker repo and tag of the Docker image
build_runtime_image
def build_runtime_image(base_image: str,
runtime_builder: RuntimeBuilder,
platform: str | None = None,
extra_deps: str | None = None,
build_folder: str | None = None,
dry_run: bool = False,
force_rebuild: bool = False) -> str
Prepares the final docker build folder. If dry_run is False, it will also build the OpenHands runtime Docker image using the docker build folder.
Arguments:
- base_image (str): The name of the base Docker image to use
- runtime_builder (RuntimeBuilder): The runtime builder to use
- platform (str): The target platform for the build (e.g. linux/amd64, linux/arm64)
- extra_deps (str):
- build_folder (str): The directory to use for the build. If not provided a temporary directory will be used
- dry_run (bool): if True, it will only ready the build folder. It will not actually build the Docker image
- force_rebuild (bool): if True, it will create the Dockerfile which uses the base_image
Returns:
- str: <image_repo>:<MD5 hash>. Where MD5 hash is the hash of the docker build folder
See https://docs.all-hands.dev/modules/usage/architecture/runtime for more details.
truncate_hash
def truncate_hash(hash: str) -> str
Convert the base16 hash to base36 and truncate at 16 characters.