Allow reusing CI Docker cache when running CI images locally
This commit is contained in:
parent
0372065097
commit
02f4ef7cde
@ -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
|
# 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}
|
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;
|
if ! isCI;
|
||||||
then
|
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,
|
# On PR CI jobs, we don't have permissions to write to the registry cache,
|
||||||
# but we can still read from it.
|
# but we can still read from it.
|
||||||
elif [[ "$PR_CI_JOB" == "1" ]];
|
elif [[ "$PR_CI_JOB" == "1" ]];
|
||||||
|
Loading…
Reference in New Issue
Block a user