about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorJakub Beránek <berykubik@gmail.com>2024-05-03 15:52:00 +0200
committerJakub Beránek <berykubik@gmail.com>2024-05-03 15:52:00 +0200
commit02f4ef7cde5ab7b69545791f3750ae03d251e8ae (patch)
tree3738483fb193ad1f45dfd1011fcf568b37cab1d1 /src
parent0372065097ec04e65fcf105c2a07f4cda5ed29f3 (diff)
downloadrust-02f4ef7cde5ab7b69545791f3750ae03d251e8ae.tar.gz
rust-02f4ef7cde5ab7b69545791f3750ae03d251e8ae.zip
Allow reusing CI Docker cache when running CI images locally
Diffstat (limited to 'src')
-rwxr-xr-xsrc/ci/docker/run.sh12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/ci/docker/run.sh b/src/ci/docker/run.sh
index acd88870b16..22dcb808c74 100755
--- a/src/ci/docker/run.sh
+++ b/src/ci/docker/run.sh
@@ -101,10 +101,18 @@ if [ -f "$docker_dir/$image/Dockerfile" ]; then
     # It seems that it cannot be the same as $IMAGE_TAG, otherwise it overwrites the cache
     CACHE_IMAGE_TAG=${REGISTRY}/${REGISTRY_USERNAME}/rust-ci-cache:${cksum}
 
-    # On non-CI jobs, we don't do any caching.
+    # On non-CI jobs, we try to download a pre-built image from the rust-lang-ci
+    # ghcr.io registry. If it is not possible, we fall back to building the image
+    # locally.
     if ! isCI;
     then
-        retry docker build --rm -t rust-ci -f "$dockerfile" "$context"
+        if docker pull "${IMAGE_TAG}"; then
+            echo "Downloaded Docker image from CI"
+            docker tag "${IMAGE_TAG}" rust-ci
+        else
+            echo "Building local Docker image"
+            retry docker build --rm -t rust-ci -f "$dockerfile" "$context"
+        fi
     # On PR CI jobs, we don't have permissions to write to the registry cache,
     # but we can still read from it.
     elif [[ "$PR_CI_JOB" == "1" ]];