kopia lustrzana https://github.com/jupyterhub/repo2docker
Allow specifying images to reuse cache from
This lets us explicitly specify images that repo2docker should try to re-use cached layers from. Docker normally only looks for layers from images that were *built* locally - if we want it to look in images that were *pulled* from a registry, we need to specify it here.pull/478/head
rodzic
8c9f08cd1e
commit
1dacdd4c46
|
@ -406,6 +406,13 @@ class Repo2Docker(Application):
|
|||
help='Print the repo2docker version and exit.'
|
||||
)
|
||||
|
||||
argparser.add_argument(
|
||||
'--cache-from',
|
||||
action='append',
|
||||
default=[],
|
||||
help='Docker images to attempt to re-use cached layers from'
|
||||
)
|
||||
|
||||
return argparser
|
||||
|
||||
def json_excepthook(self, etype, evalue, traceback):
|
||||
|
@ -545,6 +552,9 @@ class Repo2Docker(Application):
|
|||
if args.subdir:
|
||||
self.subdir = args.subdir
|
||||
|
||||
if args.cache_from:
|
||||
self.cache_from = args.cache_from
|
||||
|
||||
self.environment = args.environment
|
||||
|
||||
def push_image(self):
|
||||
|
@ -719,7 +729,7 @@ class Repo2Docker(Application):
|
|||
extra=dict(phase='building'))
|
||||
|
||||
for l in picked_buildpack.build(self.output_image_spec,
|
||||
self.build_memory_limit, build_args):
|
||||
self.build_memory_limit, build_args, self.cache_from):
|
||||
if 'stream' in l:
|
||||
self.log.info(l['stream'],
|
||||
extra=dict(phase='building'))
|
||||
|
|
|
@ -449,7 +449,7 @@ class BuildPack:
|
|||
appendix=self.appendix,
|
||||
)
|
||||
|
||||
def build(self, image_spec, memory_limit, build_args):
|
||||
def build(self, image_spec, memory_limit, build_args, cache_from):
|
||||
tarf = io.BytesIO()
|
||||
tar = tarfile.open(fileobj=tarf, mode='w')
|
||||
dockerfile_tarinfo = tarfile.TarInfo("Dockerfile")
|
||||
|
@ -499,7 +499,8 @@ class BuildPack:
|
|||
decode=True,
|
||||
forcerm=True,
|
||||
rm=True,
|
||||
container_limits=limits
|
||||
container_limits=limits,
|
||||
cache_from=cache_from
|
||||
):
|
||||
yield line
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ class DockerBuildPack(BuildPack):
|
|||
with open(Dockerfile) as f:
|
||||
return f.read()
|
||||
|
||||
def build(self, image_spec, memory_limit, build_args):
|
||||
def build(self, image_spec, memory_limit, build_args, cache_from):
|
||||
"""Build a Docker image based on the Dockerfile in the source repo."""
|
||||
limits = {
|
||||
# Always disable memory swap for building, since mostly
|
||||
|
@ -37,6 +37,7 @@ class DockerBuildPack(BuildPack):
|
|||
decode=True,
|
||||
forcerm=True,
|
||||
rm=True,
|
||||
container_limits=limits
|
||||
container_limits=limits,
|
||||
cache_from=cache_from
|
||||
):
|
||||
yield line
|
||||
|
|
Ładowanie…
Reference in New Issue