def __process_dockerfile(self, dockerfile): """ :param dockerfile_full_path: :type dockerfile_full_path: str :return: self :rtype: self """ if Output.VERBOSITY_VERBOSE <= self.output.get_verbosity(): self.line('<info>-> Processing: </info>%s' % dockerfile['image']['fullname']) docker_image = dockerfile['image']['name'] parent_image_name = DockerfileUtility.image_basename( dockerfile['image']['from']) parent_image_tag = DockerfileUtility.extract_image_name_tag( dockerfile['image']['from']) if not parent_image_name in self.containers: self.containers[parent_image_name] = 'scratch' self.__append_tag(parent_image_name, 'latest') self.containers[docker_image] = parent_image_name self.__append_tag(docker_image, parent_image_tag) return self
def __process_dockerfile(self, dockerfile): """ :param dockerfile_full_path: :type dockerfile_full_path: str :return: self :rtype: self """ if Output.VERBOSITY_VERBOSE <= self.output.get_verbosity(): self.line('<info>-> Processing: </info>%s' % dockerfile['image']['fullname']) docker_image = dockerfile['image']['name'] parent_image_name = DockerfileUtility.image_basename(dockerfile['image']['from']) parent_image_tag = DockerfileUtility.extract_image_name_tag(dockerfile['image']['from']) if not parent_image_name in self.containers: self.containers[parent_image_name] = 'scratch' self.__append_tag(parent_image_name, 'latest') self.containers[docker_image] = parent_image_name self.__append_tag(docker_image, parent_image_tag) return self
def pull_image(image): print ' -> Pull base image %s ' % image if configuration.get('dryRun'): return True pull_image_name = DockerfileUtility.image_basename(image) pull_image_tag = DockerfileUtility.extract_image_name_tag(image) pull_status = False for retry_count in range(0, configuration.get('retry')): pull_status = docker_client.pull_image( name=pull_image_name, tag=pull_image_tag, ) if pull_status: break elif retry_count < (configuration.get('retry') - 1): print ' failed, retrying... (try %s)' % (retry_count + 1) else: print ' failed, giving up' if not pull_status: return False return True
def pull_image(image): print ' -> Pull base image %s ' % image if configuration.get('dryRun'): return True pull_image_name = DockerfileUtility.image_basename(image) pull_image_tag = DockerfileUtility.extract_image_name_tag(image) pull_status = False for retry_count in range(0, configuration.get('retry')): pull_status = docker_client.pull_image( name=pull_image_name, tag=pull_image_tag, ) if pull_status: break elif retry_count < (configuration.get('retry') - 1): print ' failed, retrying... (try %s)' % (retry_count + 1) else: print ' failed, giving up' if not pull_status: return False return True
def task_run(docker_client, dockerfile, configuration, task): """ Build one Dockerfile """ pull_parent_image = DockerfileUtility.check_if_base_image_needs_pull(dockerfile, configuration) if configuration.get('dryRun'): print ' from: %s (pull: %s)' % (dockerfile['image']['from'], ('yes' if pull_parent_image else 'no')) print ' path: %s' % dockerfile['path'] print ' dep: %s' % (DockerBuildTaskLoader.human_task_name_list(task.task_dep) if task.task_dep else 'none') return True # Pull base image (FROM: xxx) first if pull_parent_image: print ' -> Pull base image %s ' % dockerfile['image']['from'] pull_image_name = DockerfileUtility.image_basename(dockerfile['image']['from']) pull_image_tag = DockerfileUtility.extract_image_name_tag(dockerfile['image']['from']) pull_status = False for retry_count in range(0, configuration.get('retry')): pull_status = docker_client.pull_image( name=pull_image_name, tag=pull_image_tag, ) if pull_status: break elif retry_count < (configuration.get('retry') - 1): print ' failed, retrying... (try %s)' % (retry_count+1) else: print ' failed, giving up' if not pull_status: return False ## Build image print ' -> Building image %s ' % dockerfile['image']['fullname'] build_status = False for retry_count in range(0, configuration.get('retry')): build_status = docker_client.build_dockerfile( path=dockerfile['path'], name=dockerfile['image']['fullname'], nocache=configuration.get('dockerBuild.noCache'), ) if build_status: break elif retry_count < (configuration.get('retry')-1): print ' failed, retrying... (try %s)' % (retry_count+1) else: print ' failed, giving up' return build_status
def task_run(docker_client, dockerfile, configuration, task): """ Build one Dockerfile """ pull_parent_image = DockerfileUtility.check_if_base_image_needs_pull( dockerfile, configuration) if configuration.get('dryRun'): print ' from: %s (pull: %s)' % (dockerfile['image']['from'], ('yes' if pull_parent_image else 'no')) print ' path: %s' % dockerfile['path'] print ' dep: %s' % ( DockerBuildTaskLoader.human_task_name_list(task.task_dep) if task.task_dep else 'none') return True # Pull base image (FROM: xxx) first if pull_parent_image: print ' -> Pull base image %s ' % dockerfile['image']['from'] pull_image_name = DockerfileUtility.image_basename( dockerfile['image']['from']) pull_image_tag = DockerfileUtility.extract_image_name_tag( dockerfile['image']['from']) pull_status = False for retry_count in range(0, configuration.get('retry')): pull_status = docker_client.pull_image( name=pull_image_name, tag=pull_image_tag, ) if pull_status: break elif retry_count < (configuration.get('retry') - 1): print ' failed, retrying... (try %s)' % (retry_count + 1) else: print ' failed, giving up' if not pull_status: return False ## Build image print ' -> Building image %s ' % dockerfile['image']['fullname'] build_status = False for retry_count in range(0, configuration.get('retry')): build_status = docker_client.build_dockerfile( path=dockerfile['path'], name=dockerfile['image']['fullname'], nocache=configuration.get('dockerBuild.noCache'), ) if build_status: break elif retry_count < (configuration.get('retry') - 1): print ' failed, retrying... (try %s)' % (retry_count + 1) else: print ' failed, giving up' return build_status