kopia lustrzana https://github.com/jupyterhub/repo2docker
Remove docker-pull hack
No longer check if image exists by doing a docker-pull - binderhub will no longer start a build if it knows that the image already existspull/26/head
rodzic
2a092c974d
commit
51c5f72b45
|
@ -43,7 +43,7 @@ class Repo2Docker(Application):
|
||||||
Path to read traitlets configuration file from.
|
Path to read traitlets configuration file from.
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
@default('log_level')
|
@default('log_level')
|
||||||
def _default_log_level(self):
|
def _default_log_level(self):
|
||||||
return logging.INFO
|
return logging.INFO
|
||||||
|
@ -251,43 +251,29 @@ class Repo2Docker(Application):
|
||||||
s.close()
|
s.close()
|
||||||
return port
|
return port
|
||||||
|
|
||||||
def image_exists(self):
|
|
||||||
client = docker.from_env(version='auto')
|
|
||||||
# HACK: Try to just pull this and see if that works.
|
|
||||||
# if it does, then just bail.
|
|
||||||
# WHAT WE REALLY WANT IS TO NOT DO ANY WORK IF THE IMAGE EXISTS
|
|
||||||
try:
|
|
||||||
image = client.images.pull(self.output_image_spec)
|
|
||||||
return True
|
|
||||||
except docker.errors.ImageNotFound:
|
|
||||||
return False
|
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
if not self.image_exists():
|
checkout_path = os.path.join(self.git_workdir, str(uuid.uuid4()))
|
||||||
checkout_path = os.path.join(self.git_workdir, str(uuid.uuid4()))
|
self.fetch(
|
||||||
self.fetch(
|
self.repo,
|
||||||
self.repo,
|
self.ref,
|
||||||
self.ref,
|
checkout_path
|
||||||
checkout_path
|
)
|
||||||
)
|
|
||||||
for bp_class in self.buildpacks:
|
|
||||||
bp = bp_class(parent=self, log=self.log, capture=self.json_logs)
|
|
||||||
if bp.detect(checkout_path):
|
|
||||||
self.log.info('Using %s builder\n', bp.name, extra=dict(phase='building'))
|
|
||||||
bp.build(checkout_path, self.ref, self.output_image_spec)
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
self.log.error('Could not figure out how to build this repository! Tell us?', extra=dict(phase='failed'))
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
if self.cleanup_checkout:
|
for bp_class in self.buildpacks:
|
||||||
shutil.rmtree(checkout_path)
|
bp = bp_class(parent=self, log=self.log, capture=self.json_logs)
|
||||||
|
if bp.detect(checkout_path):
|
||||||
|
self.log.info('Using %s builder\n', bp.name, extra=dict(phase='building'))
|
||||||
|
bp.build(checkout_path, self.ref, self.output_image_spec)
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
self.log.error('Could not figure out how to build this repository! Tell us?', extra=dict(phase='failed'))
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
if self.cleanup_checkout:
|
||||||
|
shutil.rmtree(checkout_path)
|
||||||
|
|
||||||
if self.push:
|
if self.push:
|
||||||
self.push_image()
|
self.push_image()
|
||||||
|
|
||||||
if self.run:
|
if self.run:
|
||||||
self.run_image()
|
self.run_image()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue