We have a number of "in_container" scripts written in Bash, They are doing a number of houseekeeping stuff but since we already have Python 3.7+ inside the CI image, we could modularise them more and make them run from external and simplify entrypoint_ci (for example separate script for tests).
context = known_contexts[preferred_context_name]
        except KeyError:
            continue
        # On 
        if context["DockerEndpoint"] == "npipe:////./pipe/dockerDesktopLinuxEngine":
            continue
        get_console().print(f"[info]Using {preferred_context_name} as context.[/]")
        return preferred_context_name
    fallback_context = next(iter(known_contexts))
    get_console().print(
        f"[warning]Could not use any of the preferred docker contexts {PREFERRED_CONTEXTS}.\n"
        f"Using {fallback_context} as context.[/]"
    )
    return fallback_context
def get_and_use_docker_context(context: str):
    if context == "autodetect":
        context = autodetect_docker_context()
    output = run_command(["docker", "context", "use", context], check=False)
    if output.returncode != 0:
        get_console().print(
            f"[warning] Could no use the context {context}. Continuing with current context[/]"
        )
    return context
def get_docker_build_env(image_params: CommonBuildParams) -> dict[str, str]:
    env = os.environ.copy()
    env["DOCKER_BUILDKIT"] = "1"
    if image_params.docker_host:
        env["DOCKER_HOST"] = image_params.docker_host
    return env
def bring_compose_project_down(preserve_volumes: bool, shell_params: ShellParams):