1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/hack/make/.ensure-frozen-images
Tianon Gravi 793ebba3d6 Enforce our use of the explicitly frozen images
This requires that any environment where we wish to run the integration-cli tests includes both the `Dockerfile` and `curl`, which has been deemed an appropriate and acceptable trade-off.

Signed-off-by: Andrew "Tianon" Page <admwiggin@gmail.com>
2015-03-16 14:42:59 -06:00

37 lines
968 B
Bash

#!/bin/bash
set -e
# this list should match roughly what's in the Dockerfile (minus the explicit image IDs, of course)
images=(
busybox:latest
hello-world:frozen
)
if ! docker inspect "${images[@]}" &> /dev/null; then
hardCodedDir='/docker-frozen-images'
if [ -d "$hardCodedDir" ]; then
( set -x; tar -cC "$hardCodedDir" . | docker load )
else
dir="$DEST/frozen-images"
# extract the exact "RUN download-frozen-image.sh" line from the Dockerfile itself for consistency
# NOTE: this will fail if either "curl" is not installed or if the Dockerfile is not available/readable
awk '
$1 == "RUN" && $2 == "./contrib/download-frozen-image.sh" {
for (i = 2; i < NF; i++)
printf ( $i == "'"$hardCodedDir"'" ? "'"$dir"'" : $i ) " ";
print $NF;
if (/\\$/) {
inCont = 1;
next;
}
}
inCont {
print;
if (!/\\$/) {
inCont = 0;
}
}
' Dockerfile | sh -x
( set -x; tar -cC "$dir" . | docker load )
fi
fi