def build(model_path='.', docker_registry=None, push=True, no_cache=False):
    'Builds the model into a Dockerised model server image.'
    model_path = osp.abspath(model_path)
    (model_tag, model_version) = get_model_tag_and_version(model_path)
    model_path = osp.abspath(model_path)
    image_name_parts = [model_tag]
    if (docker_registry is not None):
        image_name_parts.insert(0, docker_registry)
    image_name = '/'.join(image_name_parts)
    docker_tag = ((image_name + ':') + model_version)
    cmd = ['docker', 'build', model_path]
    cmd += ['-t', docker_tag]
    if no_cache:
        cmd += ['--no-cache']
    logger.info(' '.join(cmd))
    result = subprocess.run(cmd, check=True)
    if (result.returncode != 0):
        return result.returncode
    logger.info(('Successfully built ' + docker_tag))
    if (not push):
        return 0
    cmd = ['docker', 'push', docker_tag]
    logger.info(' '.join(cmd))
    result = subprocess.run(cmd, check=True)
    return result.returncode
Builds the model into a Dockerised model server image.
def build(model_path='.', docker_registry=None, push=True, no_cache=False):
    
    model_path = osp.abspath(model_path)
    (model_tag, model_version) = get_model_tag_and_version(model_path)
    model_path = osp.abspath(model_path)
    image_name_parts = [model_tag]
    if (docker_registry is not None):
        image_name_parts.insert(0, docker_registry)
    image_name = '/'.join(image_name_parts)
    docker_tag = ((image_name + ':') + model_version)
    cmd = ['docker', 'build', model_path]
    cmd += ['-t', docker_tag]
    if no_cache:
        cmd += ['--no-cache']
    logger.info(' '.join(cmd))
    result = subprocess.run(cmd, check=True)
    if (result.returncode != 0):
        return result.returncode
    logger.info(('Successfully built ' + docker_tag))
    if (not push):
        return 0
    cmd = ['docker', 'push', docker_tag]
    logger.info(' '.join(cmd))
    result = subprocess.run(cmd, check=True)
    return result.returncode