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
|
|
|
|
)
|
|
|
|
|
2016-03-10 22:19:33 -05:00
|
|
|
if [ "$TEST_IMAGE_NAMESPACE" ]; then
|
2016-01-05 00:50:15 -05:00
|
|
|
for (( i = 0; i < ${#images[@]}; i++ )); do
|
2016-03-10 22:19:33 -05:00
|
|
|
images[$i]="$TEST_IMAGE_NAMESPACE/${images[$i]}"
|
2016-01-05 00:50:15 -05:00
|
|
|
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-03-10 22:19:33 -05:00
|
|
|
' "$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-03-10 22:19:33 -05:00
|
|
|
if [ "$TEST_IMAGE_NAMESPACE" ]; then
|
2016-01-05 00:50:15 -05:00
|
|
|
for image in "${images[@]}"; do
|
2016-03-10 22:19:33 -05:00
|
|
|
target="${image#$TEST_IMAGE_NAMESPACE/}"
|
2016-01-05 00:50:15 -05:00
|
|
|
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
|