def push_image(self, tag=None): image = self.image[self.registry:tag:self.account] fabricio.local( 'docker push {image}'.format(image=image), quiet=False, use_cache=True, )
def push_image(self, tag=None): image = self.image[self.registry:tag:self.account] fabricio.local( 'docker push {image}'.format(image=image), quiet=False, use_cache=True, )
def prepare(self, tag=None, **kwargs): """ build Docker image (see 'docker build --help' for available options) """ # default options kwargs.setdefault('pull', True) kwargs.setdefault('force-rm', True) for key, value in kwargs.items(): try: kwargs[key] = utils.strtobool(value) except ValueError: pass options = utils.Options(tag=self.image[self.registry:tag:self.account], **kwargs) fabricio.local( 'docker build {options} {build_path}'.format( build_path=self.build_path, options=options, ), quiet=False, use_cache=True, ) self.delete_dangling_images()
def prepare(self, tag=None): """ prepare[:tag=None] - prepare Docker image """ fabricio.local( 'docker pull {image}'.format(image=self.image[tag]), quiet=False, use_cache=True, )
def delete_dangling_images(self): # pragma: no cover warnings.warn( 'delete_dangling_images() is deprecated and will be removed in v0.6', # noqa DeprecationWarning, ) warnings.warn( 'delete_dangling_images() is deprecated and will be removed in v0.6', # noqa RuntimeWarning, stacklevel=self._warnings_stacklevel, ) fabricio.local(dangling_images_delete_command(), ignore_errors=True)
def prepare(self, tag=None): """ prepare Docker image """ fabricio.local( 'docker pull {image}'.format(image=self.image[tag]), quiet=False, use_cache=True, ) self.delete_dangling_images()
def delete_dangling_images(self): # pragma: no cover warnings.warn( 'delete_dangling_images() is deprecated and will be removed in v0.6', # noqa DeprecationWarning, ) warnings.warn( 'delete_dangling_images() is deprecated and will be removed in v0.6', # noqa RuntimeWarning, stacklevel=self._warnings_stacklevel, ) fabricio.local(dangling_images_delete_command(), ignore_errors=True)
def prepare(self, tag=None): """ download Docker image from the original registry """ if self.registry is None and self.account is None: return fabricio.local( 'docker pull {image}'.format(image=self.image[tag]), quiet=False, use_cache=True, ) self.delete_dangling_images()
def prepare(self, tag=None): """ prepare[:tag=None] - prepare Docker image """ fabricio.local( 'docker build --tag {tag} {build_path}'.format( tag=self.image[tag], build_path=self.build_path, ), quiet=False, use_cache=True, )
def delete_dangling_images(): if os.name == 'posix': # macOS, Linux, etc. fabricio.local( 'for img in $(docker images --filter "dangling=true" --quiet); ' 'do docker rmi "$img"; done' ) elif os.name == 'nt': # Windows fabricio.local( "for /F %i in ('docker images --filter \"dangling=true\" " "--quiet') do @docker rmi %i" )
def prepare(self, tag=None, no_cache=False): """ prepare Docker image """ options = Options([ ('tag', str(self.image[tag])), ('no-cache', strtobool(no_cache)), ('pull', True), ]) fabricio.local( 'docker build {options} {build_path}'.format( build_path=self.build_path, options=options, ), quiet=False, use_cache=True, ) self.delete_dangling_images()
def prepare(self, tag=None, no_cache=False): """ build Docker image """ options = utils.Options([ ('tag', self.image[self.registry:tag:self.account]), ('no-cache', utils.strtobool(no_cache)), ('pull', True), ]) fabricio.local( 'docker build {options} {build_path}'.format( build_path=self.build_path, options=options, ), quiet=False, use_cache=True, ) self.delete_dangling_images()
def push(self, tag=None): """ push downloaded Docker image to the registry """ if self.registry is None and self.account is None: return tag_with_registry = str(self.image[self.registry:tag:self.account]) fabricio.local( 'docker tag {image} {tag}'.format( image=self.image[tag], tag=tag_with_registry, ), use_cache=True, ) self.push_image(tag=tag) fabricio.local( 'docker rmi {tag}'.format(tag=tag_with_registry), use_cache=True, )
def push(self, tag=None): """ push downloaded Docker image to intermediate registry """ if self.registry is None and self.account is None: return image = self.image[tag] if not image: return proxy_tag = image[self.registry:tag:self.account] fabricio.local( 'docker tag {image} {tag}'.format( image=image, tag=proxy_tag, ), use_cache=True, ) self.push_image(tag=tag) fabricio.local( 'docker rmi {tag}'.format(tag=proxy_tag), use_cache=True, )
def push(self, tag=None): """ push downloaded Docker image to intermediate registry """ if self.registry is None and self.account is None: return image = self.image[tag] if not image: return proxy_tag = image[self.registry:tag:self.account] fabricio.local( 'docker tag {image} {tag}'.format( image=image, tag=proxy_tag, ), use_cache=True, ) self.push_image(tag=tag) fabricio.local( 'docker rmi {tag}'.format(tag=proxy_tag), use_cache=True, )
def push(self, tag=None): """ push[:tag=None] - push Docker image to registry """ local_tag = str(self.image[self.local_registry:tag]) fabricio.local( 'docker tag {image} {tag}'.format( image=self.image[tag], tag=local_tag, ), use_cache=True, ) fabricio.local( 'docker push {tag}'.format(tag=local_tag), quiet=False, use_cache=True, ) fabricio.local( 'docker rmi {tag}'.format(tag=local_tag), use_cache=True, )
def push(self, tag=None): """ push Docker image to registry """ local_tag = str(self.image[self.local_registry:tag]) fabricio.local( 'docker tag {image} {tag}'.format( image=self.image[tag], tag=local_tag, ), use_cache=True, ) fabricio.local( 'docker push {tag}'.format(tag=local_tag), quiet=False, use_cache=True, ) fabricio.local( 'docker rmi {tag}'.format(tag=local_tag), use_cache=True, )
def delete_dangling_images(): fabricio.local( 'for img in $(docker images --filter "dangling=true" --quiet); ' 'do docker rmi "$img"; done' )
def delete_dangling_images(): fabricio.local(dangling_images_delete_command(), ignore_errors=True)
def test_local(self, local): local.__name__ = 'mock' try: fabricio.local('command', use_cache=True) except RuntimeError: pass try: fabricio.local('command', use_cache=True) except RuntimeError: pass local.assert_has_calls([ mock.call('command'), mock.call('command'), ]) self.assertEqual(2, local.call_count) local.reset_mock() fabricio.local('command', ignore_errors=True) fabricio.local('command', ignore_errors=True) local.assert_has_calls([ mock.call('command'), mock.call('command'), ]) self.assertEqual(2, local.call_count) local.reset_mock() fabricio.local('command', ignore_errors=True, use_cache=True) fabricio.local('command', ignore_errors=True, use_cache=True) local.assert_called_once_with('command') local.reset_mock() fabricio.local('command1', ignore_errors=True, use_cache=True) fabricio.local('command2', ignore_errors=True, use_cache=True) local.assert_has_calls([ mock.call('command1'), mock.call('command2'), ]) self.assertEqual(2, local.call_count)