Skip to content

Commit 0372065

Browse files
committed
Calculate the Docker hash key also locally
1 parent 27d1d0a commit 0372065

File tree

1 file changed

+29
-31
lines changed

1 file changed

+29
-31
lines changed

src/ci/docker/run.sh

Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -50,37 +50,35 @@ fi
5050
CACHE_DOMAIN="${CACHE_DOMAIN:-ci-caches.rust-lang.org}"
5151

5252
if [ -f "$docker_dir/$image/Dockerfile" ]; then
53-
if isCI; then
54-
hash_key=/tmp/.docker-hash-key.txt
55-
rm -f "${hash_key}"
56-
echo $image >> $hash_key
57-
58-
cat "$docker_dir/$image/Dockerfile" >> $hash_key
59-
# Look for all source files involves in the COPY command
60-
copied_files=/tmp/.docker-copied-files.txt
61-
rm -f "$copied_files"
62-
for i in $(sed -n -e '/^COPY --from=/! s/^COPY \(.*\) .*$/\1/p' \
63-
"$docker_dir/$image/Dockerfile"); do
64-
# List the file names
65-
find "$script_dir/$i" -type f >> $copied_files
66-
done
67-
# Sort the file names and cat the content into the hash key
68-
sort $copied_files | xargs cat >> $hash_key
69-
70-
# Include the architecture in the hash key, since our Linux CI does not
71-
# only run in x86_64 machines.
72-
uname -m >> $hash_key
73-
74-
# Include cache version. Can be used to manually bust the Docker cache.
75-
echo "2" >> $hash_key
76-
77-
echo "Image input"
78-
cat $hash_key
79-
80-
cksum=$(sha512sum $hash_key | \
81-
awk '{print $1}')
82-
echo "Image input checksum ${cksum}"
83-
fi
53+
hash_key=/tmp/.docker-hash-key.txt
54+
rm -f "${hash_key}"
55+
echo $image >> $hash_key
56+
57+
cat "$docker_dir/$image/Dockerfile" >> $hash_key
58+
# Look for all source files involves in the COPY command
59+
copied_files=/tmp/.docker-copied-files.txt
60+
rm -f "$copied_files"
61+
for i in $(sed -n -e '/^COPY --from=/! s/^COPY \(.*\) .*$/\1/p' \
62+
"$docker_dir/$image/Dockerfile"); do
63+
# List the file names
64+
find "$script_dir/$i" -type f >> $copied_files
65+
done
66+
# Sort the file names and cat the content into the hash key
67+
sort $copied_files | xargs cat >> $hash_key
68+
69+
# Include the architecture in the hash key, since our Linux CI does not
70+
# only run in x86_64 machines.
71+
uname -m >> $hash_key
72+
73+
# Include cache version. Can be used to manually bust the Docker cache.
74+
echo "2" >> $hash_key
75+
76+
echo "Image input"
77+
cat $hash_key
78+
79+
cksum=$(sha512sum $hash_key | \
80+
awk '{print $1}')
81+
echo "Image input checksum ${cksum}"
8482

8583
dockerfile="$docker_dir/$image/Dockerfile"
8684
if [ -x /usr/bin/cygpath ]; then

0 commit comments

Comments
 (0)