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 949a21b55f Move scripts back to hack/, leave docs in project/
This also removes the now-defunct `*maintainer*.sh` scripts that don't work with the new TOML format, and moves a couple not-build-or-release-related scripts to `contrib/` instead.

Signed-off-by: Andrew "Tianon" Page <admwiggin@gmail.com>
2015-03-13 14:04:08 -06:00

43 lines
1.1 KiB
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:latest
)
if ! docker inspect "${images[@]}" &> /dev/null; then
hardCodedDir='/docker-frozen-images'
if [ -d "$hardCodedDir" ]; then
( set -x; tar -cC "$hardCodedDir" . | docker load )
elif [ -e Dockerfile ] && command -v curl > /dev/null; then
# testing for "curl" because "download-frozen-image.sh" is built around curl
dir="$DEST/frozen-images"
# extract the exact "RUN download-frozen-image.sh" line from the Dockerfile itself for consistency
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 )
else
for image in "${images[@]}"; do
if ! docker inspect "$image" &> /dev/null; then
( set -x; docker pull "$image" )
fi
done
fi
fi