kopia lustrzana https://github.com/jupyterhub/repo2docker
Make push optional and default to False
Let's optimize the defaults for good commandline usage rather than for binderhub usagepull/6/head
rodzic
542c7a9a1c
commit
ae124ec2f7
|
@ -92,11 +92,20 @@ class Repo2Docker(Application):
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
|
push = Bool(
|
||||||
|
False,
|
||||||
|
config=True,
|
||||||
|
help="""
|
||||||
|
If the image should be pushed after it is built.
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
|
||||||
aliases = Dict({
|
aliases = Dict({
|
||||||
'repo': 'Repo2Docker.repo',
|
'repo': 'Repo2Docker.repo',
|
||||||
'ref': 'Repo2Docker.ref',
|
'ref': 'Repo2Docker.ref',
|
||||||
'image': 'Repo2Docker.output_image_spec',
|
'image': 'Repo2Docker.output_image_spec',
|
||||||
'clean': 'Repo2Docker.cleanup_checkout',
|
'clean': 'Repo2Docker.cleanup_checkout',
|
||||||
|
'push': 'Repo2Docker.push',
|
||||||
'f': 'Repo2Docker.config_file',
|
'f': 'Repo2Docker.config_file',
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -174,20 +183,25 @@ class Repo2Docker(Application):
|
||||||
self.log.error('Could not figure out how to build this repository! Tell us?', extra=dict(phase='failed'))
|
self.log.error('Could not figure out how to build this repository! Tell us?', extra=dict(phase='failed'))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# Build a progress setup for each layer, and only emit per-layer info every 1.5s
|
if self.push:
|
||||||
layers = {}
|
# Build a progress setup for each layer, and only emit per-layer info every 1.5s
|
||||||
last_emit_time = time.time()
|
layers = {}
|
||||||
for line in client.push(self.output_image_spec, stream=True):
|
last_emit_time = time.time()
|
||||||
progress = json.loads(line.decode('utf-8'))
|
for line in client.push(self.output_image_spec, stream=True):
|
||||||
if 'id' not in progress:
|
progress = json.loads(line.decode('utf-8'))
|
||||||
continue
|
if 'error' in progress:
|
||||||
if 'progressDetail' in progress and progress['progressDetail']:
|
self.log.error(progress['error'], extra=dict(phase='failed'))
|
||||||
layers[progress['id']] = progress['progressDetail']
|
sys.exit(1)
|
||||||
else:
|
if 'id' not in progress:
|
||||||
layers[progress['id']] = progress['status']
|
continue
|
||||||
if time.time() - last_emit_time > 1.5:
|
if 'progressDetail' in progress and progress['progressDetail']:
|
||||||
self.log.info('Pushing image', extra=dict(progress=layers, phase='pushing'))
|
layers[progress['id']] = progress['progressDetail']
|
||||||
last_emit_time = time.time()
|
else:
|
||||||
|
layers[progress['id']] = progress['status']
|
||||||
|
if time.time() - last_emit_time > 1.5:
|
||||||
|
self.log.info('Pushing image', extra=dict(progress=layers, phase='pushing'))
|
||||||
|
last_emit_time = time.time()
|
||||||
|
|
||||||
|
|
||||||
if self.cleanup_checkout:
|
if self.cleanup_checkout:
|
||||||
shutil.rmtree(checkout_path)
|
shutil.rmtree(checkout_path)
|
||||||
|
|
Ładowanie…
Reference in New Issue