2015-03-06 20:12:41 -05:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
|
2016-01-05 00:50:15 -05:00
|
|
|
# image list should match what's in the Dockerfile (minus the explicit images IDs)
|
|
|
|
images=(
|
2016-01-14 16:51:30 -05:00
|
|
|
buildpack-deps:jessie
|
2016-01-05 00:50:15 -05:00
|
|
|
busybox:latest
|
|
|
|
debian:jessie
|
|
|
|
hello-world:latest
|
|
|
|
)
|
|
|
|
|
|
|
|
imagePrefix=
|
2015-12-03 17:44:28 -05:00
|
|
|
case "$DOCKER_ENGINE_OSARCH" in
|
2015-12-10 02:18:16 -05:00
|
|
|
linux/arm)
|
2016-01-05 00:50:15 -05:00
|
|
|
imagePrefix='armhf'
|
2015-12-03 17:44:28 -05:00
|
|
|
;;
|
2016-01-15 09:25:03 -05:00
|
|
|
linux/arm64)
|
|
|
|
imagePrefix='aarch64'
|
|
|
|
;;
|
2015-12-03 17:44:28 -05:00
|
|
|
linux/ppc64le)
|
2016-01-05 00:50:15 -05:00
|
|
|
imagePrefix='ppc64le'
|
2015-12-03 17:44:28 -05:00
|
|
|
;;
|
|
|
|
linux/s390x)
|
2016-01-05 00:50:15 -05:00
|
|
|
imagePrefix='s390x'
|
2015-12-03 17:44:28 -05:00
|
|
|
;;
|
|
|
|
esac
|
2015-11-05 09:38:41 -05:00
|
|
|
|
2016-01-05 00:50:15 -05:00
|
|
|
if [ "$imagePrefix" ]; then
|
|
|
|
for (( i = 0; i < ${#images[@]}; i++ )); do
|
|
|
|
images[$i]="$imagePrefix/${images[$i]}"
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2015-03-06 20:12:41 -05:00
|
|
|
if ! docker inspect "${images[@]}" &> /dev/null; then
|
|
|
|
hardCodedDir='/docker-frozen-images'
|
|
|
|
if [ -d "$hardCodedDir" ]; then
|
2016-01-08 14:43:59 -05:00
|
|
|
# Do not use a subshell for the following command. Windows to Linux CI
|
2015-12-02 14:26:13 -05:00
|
|
|
# runs bash 3.x so will not trap an error in a subshell.
|
|
|
|
# http://stackoverflow.com/questions/22630363/how-does-set-e-work-with-subshells
|
|
|
|
set -x; tar -cC "$hardCodedDir" . | docker load; set +x
|
2015-03-16 16:37:49 -04:00
|
|
|
else
|
2015-03-06 20:12:41 -05:00
|
|
|
dir="$DEST/frozen-images"
|
2015-08-31 13:06:22 -04:00
|
|
|
# extract the exact "RUN download-frozen-image-v2.sh" line from the Dockerfile itself for consistency
|
|
|
|
# NOTE: this will fail if either "curl" or "jq" is not installed or if the Dockerfile is not available/readable
|
2015-03-06 20:12:41 -05:00
|
|
|
awk '
|
2015-08-31 13:06:22 -04:00
|
|
|
$1 == "RUN" && $2 == "./contrib/download-frozen-image-v2.sh" {
|
2015-03-06 20:12:41 -05:00
|
|
|
for (i = 2; i < NF; i++)
|
|
|
|
printf ( $i == "'"$hardCodedDir"'" ? "'"$dir"'" : $i ) " ";
|
|
|
|
print $NF;
|
|
|
|
if (/\\$/) {
|
|
|
|
inCont = 1;
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
inCont {
|
|
|
|
print;
|
|
|
|
if (!/\\$/) {
|
|
|
|
inCont = 0;
|
|
|
|
}
|
|
|
|
}
|
2016-01-05 00:50:15 -05:00
|
|
|
' "${DOCKERFILE:=Dockerfile}" | sh -x
|
2016-01-08 14:43:59 -05:00
|
|
|
# Do not use a subshell for the following command. Windows to Linux CI
|
2015-12-02 14:26:13 -05:00
|
|
|
# runs bash 3.x so will not trap an error in a subshell.
|
|
|
|
# http://stackoverflow.com/questions/22630363/how-does-set-e-work-with-subshells
|
|
|
|
set -x; tar -cC "$dir" . | docker load; set +x
|
2015-03-06 20:12:41 -05:00
|
|
|
fi
|
|
|
|
fi
|
2015-11-05 09:38:41 -05:00
|
|
|
|
2016-01-05 00:50:15 -05:00
|
|
|
if [ "$imagePrefix" ]; then
|
|
|
|
for image in "${images[@]}"; do
|
|
|
|
target="${image#$imagePrefix/}"
|
|
|
|
if [ "$target" != "$image" ]; then
|
|
|
|
# tag images to ensure that all integrations work with the defined image names
|
|
|
|
docker tag "$image" "$target"
|
|
|
|
# then remove original tags as these make problems with later tests (e.g., TestInspectApiImageResponse)
|
|
|
|
docker rmi "$image"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
# explicitly rename "hello-world:latest" to ":frozen" for the test that uses it
|
|
|
|
docker tag hello-world:latest hello-world:frozen
|
|
|
|
docker rmi hello-world:latest
|