ci/build.py
def build_docker(platform: str, docker_binary: str, registry: str, num_retries: int) -> None:
    """
    Build a container for the given platform
    :param platform: Platform
    :param docker_binary: docker binary to use (docker/nvidia-docker)
    :param registry: Dockerhub registry name
    :param num_retries: Number of retries to build the docker image
    :return: Id of the top level image
    """

    tag = get_docker_tag(platform=platform, registry=registry)
    logging.info("Building container tagged '%s' with %s", tag, docker_binary)
    #
    # We add a user with the same group as the executing non-root user so files created in the
    # container match permissions of the local user. Same for the group.
    #
    # These variables are used in the docker files to create user and group with these ids.
    # see: docker/install/ubuntu_adduser.sh
    #
    # cache-from is needed so we use the cached images tagged from the remote via
    # docker pull see: docker_cache.load_docker_cache
    #
    # This doesn't work with multi head docker files.
    # 

    for i in range(num_retries):
        logging.info('%d out of %d tries to build the docker image.', i + 1, num_retries)

        cmd = [docker_binary, "build",
               "-f", get_dockerfile(platform),
               "--build-arg", "USER_ID={}".format(os.getuid()),
               "--build-arg", "GROUP_ID={}".format(os.getgid()),
               "--cache-from", tag,
               "-t", tag,
               "docker"]
        logging.info("Running command: '%s'", ' '.join(cmd))
        try:
            check_call(cmd)
            # Docker build was successful. Call break to break out of the retry mechanism
            break
        except subprocess.CalledProcessError as e:
            saved_exception = e
            logging.error('Failed to build docker image')
            # Building the docker image failed. Call continue to trigger the retry mechanism
            continue
    else:
        # Num retries exceeded
        logging.exception('Exception during build of docker image', saved_exception)
        logging.fatal('Failed to build the docker image, aborting...')
        sys.exit(1)

    # Get image id by reading the tag. It's guaranteed (except race condition) that the tag exists. Otherwise, the
    # check_call would have failed
    image_id = _get_local_image_id(docker_binary=docker_binary, docker_tag=tag)
    if not image_id:
        raise FileNotFoundError('Unable to find docker image id matching with {}'.format(tag))
    return image_id

    Build a container for the given platform
    :param platform: Platform
    :param docker_binary: docker binary to use (docker/nvidia-docker)
    :param registry: Dockerhub registry name
    :param num_retries: Number of retries to build the docker image
    :return: Id of the top level image
    
Build a container for the given platform
Build a container for the given platform
def build_docker(platform: str, docker_binary: str, registry: str, num_retries: int) -> None:
    tag = get_docker_tag(platform=platform, registry=registry)
    logging.info("Building container tagged '%s' with %s", tag, docker_binary)
     We add a user with the same group as the executing non-root user so files created in the
     container match permissions of the local user. Same for the group.
     These variables are used in the docker files to create user and group with these ids.
     see: docker/install/ubuntu_adduser.sh
     cache-from is needed so we use the cached images tagged from the remote via
     docker pull see: docker_cache.load_docker_cache
     This doesn't work with multi head docker files.
    for i in range(num_retries):
        logging.info('%d out of %d tries to build the docker image.', i + 1, num_retries)
        cmd = [docker_binary, "build",
               "-f", get_dockerfile(platform),
               "--build-arg", "USER_ID={}".format(os.getuid()),
               "--build-arg", "GROUP_ID={}".format(os.getgid()),
               "--cache-from", tag,
               "-t", tag,
               "docker"]
        logging.info("Running command: '%s'", ' '.join(cmd))
        try:
            check_call(cmd)
             Docker build was successful. Call break to break out of the retry mechanism
            break
        except subprocess.CalledProcessError as e:
            saved_exception = e
            logging.error('Failed to build docker image')
             Building the docker image failed. Call continue to trigger the retry mechanism
            continue
    else:
         Num retries exceeded
        logging.exception('Exception during build of docker image', saved_exception)
        logging.fatal('Failed to build the docker image, aborting...')
        sys.exit(1)
     Get image id by reading the tag. It's guaranteed (except race condition) that the tag exists. Otherwise, the
     check_call would have failed
    image_id = _get_local_image_id(docker_binary=docker_binary, docker_tag=tag)
    if not image_id:
        raise FileNotFoundError('Unable to find docker image id matching with {}'.format(tag))
    return image_id
def build_docker ( platform : str , docker_binary : str , registry : str , num_retries : int ) -> None : tag = get_docker_tag ( platform = platform , registry = registry ) logging . info ( "Building container tagged '%s' with %s" , tag , docker_binary ) for i in range ( num_retries ) : logging . info ( '%d out of %d tries to build the docker image.' , i + 1 , num_retries ) cmd = [ docker_binary , "build" , "-f" , get_dockerfile ( platform ) , "--build-arg" , "USER_ID={}" . format ( os . getuid ( ) ) , "--build-arg" , "GROUP_ID={}" . format ( os . getgid ( ) ) , "--cache-from" , tag , "-t" , tag , "docker" ] logging . info ( "Running command: '%s'" , ' ' . join ( cmd ) ) try : check_call ( cmd ) break except subprocess . CalledProcessError as e : saved_exception = e logging . error ( 'Failed to build docker image' ) continue else : logging . exception ( 'Exception during build of docker image' , saved_exception ) logging . fatal ( 'Failed to build the docker image, aborting...' ) sys . exit ( 1 ) image_id = _get_local_image_id ( docker_binary = docker_binary , docker_tag = tag ) if not image_id : raise FileNotFoundError ( 'Unable to find docker image id matching with {}' . format ( tag ) ) return image_id
Build a container for the given platform
Build a container for the given platform
"""
    Build a container for the given platform
    :param platform: Platform
    :param docker_binary: docker binary to use (docker/nvidia-docker)
    :param registry: Dockerhub registry name
    :param num_retries: Number of retries to build the docker image
    :return: Id of the top level image
    """ # # We add a user with the same group as the executing non-root user so files created in the # container match permissions of the local user. Same for the group. # # These variables are used in the docker files to create user and group with these ids. # see: docker/install/ubuntu_adduser.sh # # cache-from is needed so we use the cached images tagged from the remote via # docker pull see: docker_cache.load_docker_cache # # This doesn't work with multi head docker files. #  # Docker build was successful. Call break to break out of the retry mechanism # Building the docker image failed. Call continue to trigger the retry mechanism # Num retries exceeded # Get image id by reading the tag. It's guaranteed (except race condition) that the tag exists. Otherwise, the # check_call would have failed
Id of the top level image
Id of the top level image
platform
str
None
docker_binary
str
None
registry
str
Dockerhub registry name
Dockerhub registry name
num_retries
int
Number of retries to build the docker image
Number of retries to build the docker image