本文整理匯總了Python中atomic_reactor.build.InsideBuilder.push_built_image方法的典型用法代碼示例。如果您正苦於以下問題:Python InsideBuilder.push_built_image方法的具體用法?Python InsideBuilder.push_built_image怎麽用?Python InsideBuilder.push_built_image使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類atomic_reactor.build.InsideBuilder
的用法示例。
在下文中一共展示了InsideBuilder.push_built_image方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: DockerBuildWorkflow
# 需要導入模塊: from atomic_reactor.build import InsideBuilder [as 別名]
# 或者: from atomic_reactor.build.InsideBuilder import push_built_image [as 別名]
#.........這裏部分代碼省略.........
:param plugin_files: list of str, load plugins also from these files
:param parent_registry_insecure: bool, allow connecting to parent registry over plain http
:param target_registries_insecure: bool, allow connecting to target registries over plain http
:param dont_pull_base_image: bool, don't pull or update base image specified in dockerfile
"""
self.source = get_source_instance_for(source, tmpdir=tempfile.mkdtemp())
self.image = image
self.parent_registry = parent_registry
self.parent_registry_insecure = parent_registry_insecure
self.prebuild_plugins_conf = prebuild_plugins
self.prepublish_plugins_conf = prepublish_plugins
self.postbuild_plugins_conf = postbuild_plugins
self.prebuild_results = {}
self.postbuild_results = {}
self.plugin_files = plugin_files
self.kwargs = kwargs
self.builder = None
self.build_logs = None
self.built_image_inspect = None
self.base_image_inspect = None
self.dont_pull_base_image = dont_pull_base_image
self.pulled_base_images = set()
# squashed image tarball
# set by squash plugin
self.exported_squashed_image = {}
self.tag_conf = TagConf()
self.push_conf = PushConf()
if target_registries:
self.push_conf.add_docker_registries(target_registries, insecure=target_registries_insecure)
# mapping of downloaded files; DON'T PUT ANYTHING BIG HERE!
# "path/to/file" -> "content"
self.files = {}
if kwargs:
logger.warning("unprocessed keyword arguments: %s", kwargs)
def build_docker_image(self):
"""
build docker image
:return: BuildResults
"""
self.builder = InsideBuilder(self.source, self.image)
try:
if not self.dont_pull_base_image:
self.pulled_base_images = self.builder.pull_base_image(self.parent_registry,
insecure=self.parent_registry_insecure)
self.base_image_inspect = self.builder.tasker.inspect_image(self.builder.base_image)
# time to run pre-build plugins, so they can access cloned repo,
# base image
logger.info("running pre-build plugins")
prebuild_runner = PreBuildPluginsRunner(self.builder.tasker, self, self.prebuild_plugins_conf,
plugin_files=self.plugin_files)
try:
prebuild_runner.run()
except PluginFailedException as ex:
logger.error("one or more prebuild plugins failed: %s", ex)
return
build_result = self.builder.build()
self.build_logs = build_result.logs
if not build_result.is_failed():
self.built_image_inspect = self.builder.inspect_built_image()
# run prepublish plugins
prepublish_runner = PrePublishPluginsRunner(self.builder.tasker, self, self.prepublish_plugins_conf,
plugin_files=self.plugin_files)
try:
prepublish_runner.run()
except PluginFailedException as ex:
logger.error("one or more prepublish plugins failed: %s", ex)
return
if not build_result.is_failed():
for registry in self.push_conf.docker_registries:
self.builder.push_built_image(registry.uri,
insecure=registry.insecure)
postbuild_runner = PostBuildPluginsRunner(self.builder.tasker, self, self.postbuild_plugins_conf,
plugin_files=self.plugin_files)
try:
postbuild_runner.run()
except PluginFailedException as ex:
logger.error("one or more postbuild plugins failed: %s", ex)
return
return build_result
finally:
self.source.remove_tmpdir()
示例2: DockerBuildWorkflow
# 需要導入模塊: from atomic_reactor.build import InsideBuilder [as 別名]
# 或者: from atomic_reactor.build.InsideBuilder import push_built_image [as 別名]
#.........這裏部分代碼省略.........
self.builder = None
self.build_logs = None
self.built_image_inspect = None
self._base_image_inspect = None
self.pulled_base_images = set()
# When an image is exported into tarball, it can then be processed by various plugins.
# Each plugin that transforms the image should save it as a new file and append it to
# the end of exported_image_sequence. Other plugins should then operate with last
# member of this structure. Example:
# [{'path': '/tmp/foo.tar', 'size': 12345678, 'md5sum': '<md5>', 'sha256sum': '<sha256>'}]
# You can use util.get_exported_image_metadata to create a dict to append to this list.
self.exported_image_sequence = []
self.tag_conf = TagConf()
self.push_conf = PushConf()
if target_registries:
self.push_conf.add_docker_registries(target_registries, insecure=target_registries_insecure)
# mapping of downloaded files; DON'T PUT ANYTHING BIG HERE!
# "path/to/file" -> "content"
self.files = {}
if kwargs:
logger.warning("unprocessed keyword arguments: %s", kwargs)
@property
def build_process_failed(self):
"""
Has any aspect of the build process failed?
"""
return self.build_failed or self.plugin_failed
# inspect base image lazily just before it's needed - pre plugins may change the base image
@property
def base_image_inspect(self):
if self._base_image_inspect is None:
self._base_image_inspect = self.builder.tasker.inspect_image(self.builder.base_image)
return self._base_image_inspect
def build_docker_image(self):
"""
build docker image
:return: BuildResults
"""
self.builder = InsideBuilder(self.source, self.image)
try:
# time to run pre-build plugins, so they can access cloned repo
logger.info("running pre-build plugins")
prebuild_runner = PreBuildPluginsRunner(self.builder.tasker, self, self.prebuild_plugins_conf,
plugin_files=self.plugin_files)
try:
prebuild_runner.run()
except PluginFailedException as ex:
logger.error("one or more prebuild plugins failed: %s", ex)
raise
build_result = self.builder.build()
self.build_logs = build_result.logs
self.build_failed = build_result.is_failed()
if not build_result.is_failed():
self.built_image_inspect = self.builder.inspect_built_image()
# run prepublish plugins
prepublish_runner = PrePublishPluginsRunner(self.builder.tasker, self, self.prepublish_plugins_conf,
plugin_files=self.plugin_files)
try:
prepublish_runner.run()
except PluginFailedException as ex:
logger.error("one or more prepublish plugins failed: %s", ex)
raise
if not build_result.is_failed():
for registry in self.push_conf.docker_registries:
self.builder.push_built_image(registry.uri,
insecure=registry.insecure)
postbuild_runner = PostBuildPluginsRunner(self.builder.tasker, self, self.postbuild_plugins_conf,
plugin_files=self.plugin_files)
try:
postbuild_runner.run()
except PluginFailedException as ex:
logger.error("one or more postbuild plugins failed: %s", ex)
raise
return build_result
finally:
self.source.remove_tmpdir()
exit_runner = ExitPluginsRunner(self.builder.tasker, self,
self.exit_plugins_conf,
plugin_files=self.plugin_files)
try:
exit_runner.run()
except PluginFailedException as ex:
logger.error("one or more exit plugins failed: %s", ex)