kopia lustrzana https://github.com/jupyterhub/repo2docker
further simplify s2i buildpacks
setting build_image is enough, without overriding .build()pull/7/head
rodzic
fa2bc21f87
commit
1d74762c31
|
@ -56,6 +56,10 @@ class DockerBuildPack(BuildPack):
|
||||||
|
|
||||||
|
|
||||||
class S2IBuildPack(BuildPack):
|
class S2IBuildPack(BuildPack):
|
||||||
|
# Simple subclasses of S2IBuildPack must set build_image,
|
||||||
|
# either via config or during `detect()`
|
||||||
|
build_image = Unicode('')
|
||||||
|
|
||||||
def s2i_build(self, workdir, ref, output_image_spec, build_image):
|
def s2i_build(self, workdir, ref, output_image_spec, build_image):
|
||||||
# Note: Ideally we'd just copy from workdir here, rather than clone and check out again
|
# Note: Ideally we'd just copy from workdir here, rather than clone and check out again
|
||||||
# However, setting just --copy and not specifying a ref seems to check out master for
|
# However, setting just --copy and not specifying a ref seems to check out master for
|
||||||
|
@ -76,6 +80,9 @@ class S2IBuildPack(BuildPack):
|
||||||
self.log.error('Failed to build image!', extra=dict(phase='failed'))
|
self.log.error('Failed to build image!', extra=dict(phase='failed'))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
def build(self, workdir, ref, output_image_spec):
|
||||||
|
return self.s2i_build(workdir, ref, output_image_spec, self.build_image)
|
||||||
|
|
||||||
|
|
||||||
class CondaBuildPack(S2IBuildPack):
|
class CondaBuildPack(S2IBuildPack):
|
||||||
"""Build Pack for installing from a conda environment.yml using S2I"""
|
"""Build Pack for installing from a conda environment.yml using S2I"""
|
||||||
|
@ -86,9 +93,6 @@ class CondaBuildPack(S2IBuildPack):
|
||||||
def detect(self, workdir):
|
def detect(self, workdir):
|
||||||
return os.path.exists(os.path.join(workdir, 'environment.yml'))
|
return os.path.exists(os.path.join(workdir, 'environment.yml'))
|
||||||
|
|
||||||
def build(self, workdir, ref, output_image_spec):
|
|
||||||
return self.s2i_build(workdir, ref, output_image_spec, self.build_image)
|
|
||||||
|
|
||||||
|
|
||||||
class PythonBuildPack(S2IBuildPack):
|
class PythonBuildPack(S2IBuildPack):
|
||||||
"""Build Pack for installing from a pip requirements.txt using S2I"""
|
"""Build Pack for installing from a pip requirements.txt using S2I"""
|
||||||
|
@ -110,7 +114,5 @@ class PythonBuildPack(S2IBuildPack):
|
||||||
self.runtime = f.read().strip()
|
self.runtime = f.read().strip()
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
pass
|
pass
|
||||||
|
self.build_image = self.runtime_builder_map[self.runtime]
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def build(self, workdir, ref, output_image_spec):
|
|
||||||
return self.s2i_build(workdir, ref, output_image_spec, self.runtime_builder_map[self.runtime])
|
|
||||||
|
|
Ładowanie…
Reference in New Issue