Skip to content

Commit f73e485

Browse files
committed
docker.py: fix fetching of FROM layers
This worked on a system that was already bootstrapped because the stage 2 images already existed even if they wouldn't be used. What we should have pulled down was the FROM line containers first because building on gitlab doesn't have the advantage of using our build system to build the pre-requisite bits. We still pull the image we want to build just in case we can use the cached data. Signed-off-by: Alex Bennée <[email protected]> Reviewed-by: Daniel P. Berrangé <[email protected]> Tested-by: Philippe Mathieu-Daudé <[email protected]> Message-Id: <[email protected]>
1 parent a77312e commit f73e485

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

tests/docker/docker.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -306,14 +306,18 @@ def build_image(self, tag, docker_dir, dockerfile,
306306
checksum = _text_checksum(_dockerfile_preprocess(dockerfile))
307307

308308
if registry is not None:
309-
# see if we can fetch a cache copy, may fail...
310-
pull_args = ["pull", "%s/%s" % (registry, tag)]
311-
if self._do(pull_args, quiet=quiet) == 0:
309+
sources = re.findall("FROM qemu\/(.*)", dockerfile)
310+
# Fetch any cache layers we can, may fail
311+
for s in sources:
312+
pull_args = ["pull", "%s/qemu/%s" % (registry, s)]
313+
if self._do(pull_args, quiet=quiet) != 0:
314+
registry = None
315+
break
316+
# Make substitutions
317+
if registry is not None:
312318
dockerfile = dockerfile.replace("FROM qemu/",
313319
"FROM %s/qemu/" %
314320
(registry))
315-
else:
316-
registry = None
317321

318322
tmp_df = tempfile.NamedTemporaryFile(mode="w+t",
319323
encoding='utf-8',
@@ -339,6 +343,8 @@ def build_image(self, tag, docker_dir, dockerfile,
339343
build_args += ["--build-arg", "BUILDKIT_INLINE_CACHE=1"]
340344

341345
if registry is not None:
346+
pull_args = ["pull", "%s/%s" % (registry, tag)]
347+
self._do(pull_args, quiet=quiet)
342348
cache = "%s/%s" % (registry, tag)
343349
build_args += ["--cache-from", cache]
344350
build_args += argv

0 commit comments

Comments
 (0)