Пример #1
0
def _build_save_container(platform, bucket) -> str:
    """
    Build image for passed platform and upload the cache to the specified S3 bucket
    :param platform: Platform
    :param bucket: Target s3 bucket
    :return: Platform if failed, None otherwise
    """
    docker_tag = build_util.get_docker_tag(platform)

    # Preload cache
    # TODO: Allow to disable this in order to allow clean rebuilds
    load_docker_cache(bucket_name=bucket, docker_tag=docker_tag)

    # Start building
    logging.debug('Building {} as {}'.format(platform, docker_tag))
    try:
        image_id = build_util.build_docker(docker_binary='docker',
                                           platform=platform)
        logging.info('Built {} as {}'.format(docker_tag, image_id))

        # Compile and upload tarfile
        _compile_upload_cache_file(bucket_name=bucket,
                                   docker_tag=docker_tag,
                                   image_id=image_id)
        return None
    except Exception:
        logging.exception(
            'Unexpected exception during build of {}'.format(docker_tag))
        return platform
Пример #2
0
def _build_save_container(platform, registry, load_cache) -> str:
    """
    Build image for passed platform and upload the cache to the specified S3 bucket
    :param platform: Platform
    :param registry: Docker registry name
    :param load_cache: Load cache before building
    :return: Platform if failed, None otherwise
    """
    docker_tag = build_util.get_docker_tag(platform=platform,
                                           registry=registry)

    # Preload cache
    if load_cache:
        load_docker_cache(registry=registry, docker_tag=docker_tag)

    # Start building
    logging.debug('Building %s as %s', platform, docker_tag)
    try:
        # Increase the number of retries for building the cache.
        image_id = build_util.build_docker(docker_binary='docker',
                                           platform=platform,
                                           registry=registry,
                                           num_retries=10)
        logging.info('Built %s as %s', docker_tag, image_id)

        # Push cache to registry
        _upload_image(registry=registry,
                      docker_tag=docker_tag,
                      image_id=image_id)
        return None
    except Exception:
        logging.exception('Unexpected exception during build of %s',
                          docker_tag)
        return platform
Пример #3
0
def _build_save_container(platform, registry, load_cache) -> Optional[str]:
    """
    Build image for passed platform and upload the cache to the specified S3 bucket
    :param platform: Platform
    :param registry: Docker registry name
    :param load_cache: Load cache before building
    :return: Platform if failed, None otherwise
    """
    docker_tag = build_util.get_docker_tag(platform=platform, registry=registry)

    # Preload cache
    if load_cache:
        load_docker_cache(registry=registry, docker_tag=docker_tag)

    # Start building
    logging.debug('Building %s as %s', platform, docker_tag)
    try:
        # Increase the number of retries for building the cache.
        image_id = build_util.build_docker(docker_binary='docker', platform=platform, registry=registry, num_retries=10, no_cache=False)
        logging.info('Built %s as %s', docker_tag, image_id)

        # Push cache to registry
        _upload_image(registry=registry, docker_tag=docker_tag, image_id=image_id)
        return None
    except Exception:
        logging.exception('Unexpected exception during build of %s', docker_tag)
        return platform
Пример #4
0
def _build_save_container(platform, bucket) -> str:
    """
    Build image for passed platform and upload the cache to the specified S3 bucket
    :param platform: Platform
    :param bucket: Target s3 bucket
    :return: Platform if failed, None otherwise
    """
    docker_tag = build_util.get_docker_tag(platform)

    # Preload cache
    # TODO: Allow to disable this in order to allow clean rebuilds
    load_docker_cache(bucket_name=bucket, docker_tag=docker_tag)

    # Start building
    logging.debug('Building {} as {}'.format(platform, docker_tag))
    try:
        image_id = build_util.build_docker(docker_binary='docker', platform=platform)
        logging.info('Built {} as {}'.format(docker_tag, image_id))

        # Compile and upload tarfile
        _compile_upload_cache_file(bucket_name=bucket, docker_tag=docker_tag, image_id=image_id)
        return None
    except Exception:
        logging.exception('Unexpected exception during build of {}'.format(docker_tag))
        return platform
Пример #5
0
def _build_save_container(platform, registry, load_cache) -> Optional[str]:
    """
    Build image for passed platform and upload the cache to the specified S3 bucket
    :param platform: Platform
    :param registry: Docker registry name
    :param load_cache: Load cache before building
    :return: Platform if failed, None otherwise
    """
    # Case 1: docker-compose
    if platform in build_util.DOCKER_COMPOSE_WHITELIST:
        build_util.build_docker(platform=platform,
                                registry=registry,
                                num_retries=10,
                                no_cache=False)
        push_cmd = ['docker-compose', 'push', platform]
        subprocess.check_call(push_cmd)
        return None

    # Case 2: Deprecated way, will be removed
    docker_tag = build_util.get_docker_tag(platform=platform,
                                           registry=registry)
    # Preload cache
    if load_cache:
        load_docker_cache(registry=registry, docker_tag=docker_tag)

    # Start building
    logging.debug('Building %s as %s', platform, docker_tag)
    try:
        # Increase the number of retries for building the cache.
        image_id = build_util.build_docker(platform=platform,
                                           registry=registry,
                                           num_retries=10,
                                           no_cache=False)
        logging.info('Built %s as %s', docker_tag, image_id)

        # Push cache to registry
        _upload_image(registry=registry,
                      docker_tag=docker_tag,
                      image_id=image_id)
        return None
    except Exception:
        logging.exception('Unexpected exception during build of %s',
                          docker_tag)
        return platform
Пример #6
0
 def primed_cache_lambda_func():
     build_util.build_docker(docker_binary='docker', platform=platform, registry=DOCKER_REGISTRY_PATH)
Пример #7
0
 def warm_up_lambda_func():
     build_util.build_docker(docker_binary='docker', platform=platform, registry=DOCKER_REGISTRY_PATH)
Пример #8
0
 def primed_cache_lambda_func():
     build_util.build_docker(docker_binary='docker',
                             platform=platform,
                             registry=DOCKER_REGISTRY_PATH)
Пример #9
0
 def warm_up_lambda_func():
     build_util.build_docker(docker_binary='docker',
                             platform=platform,
                             registry=DOCKER_REGISTRY_PATH)
 def primed_cache_lambda_func():
     build_util.build_docker(docker_binary='docker',
                             platform=platform,
                             registry=DOCKER_REGISTRY_PATH,
                             num_retries=3,
                             no_cache=False)