2015-03-06 20:12:41 -05:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# this list should match roughly what's in the Dockerfile (minus the explicit image IDs, of course)
|
|
|
|
images=(
|
|
|
|
busybox:latest
|
2015-03-16 15:22:00 -04:00
|
|
|
hello-world:frozen
|
2015-03-06 20:12:41 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
if ! docker inspect "${images[@]}" &> /dev/null; then
|
|
|
|
hardCodedDir='/docker-frozen-images'
|
|
|
|
if [ -d "$hardCodedDir" ]; then
|
|
|
|
( set -x; tar -cC "$hardCodedDir" . | docker load )
|
2015-03-16 16:37:49 -04:00
|
|
|
else
|
2015-03-06 20:12:41 -05:00
|
|
|
dir="$DEST/frozen-images"
|
|
|
|
# extract the exact "RUN download-frozen-image.sh" line from the Dockerfile itself for consistency
|
2015-03-16 16:37:49 -04:00
|
|
|
# NOTE: this will fail if either "curl" is not installed or if the Dockerfile is not available/readable
|
2015-03-06 20:12:41 -05:00
|
|
|
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
|