Refactor busybox downloading as generic "frozen-images"
This makes it much simpler to add new "frozen" images -- simply add them to the `Dockerfile` and in `hack/make/.ensure-frozen-images` and you're off to the races. Signed-off-by: Andrew "Tianon" Page <admwiggin@gmail.com>
This commit is contained in:
parent
c5af44e6d0
commit
09b4c25852
5 changed files with 48 additions and 25 deletions
|
@ -142,9 +142,11 @@ ENV DOCKER_BUILDTAGS apparmor selinux btrfs_noversion
|
|||
# Let us use a .bashrc file
|
||||
RUN ln -sfv $PWD/.bashrc ~/.bashrc
|
||||
|
||||
# Get the "busybox" image so we can "docker load" locally instead of pulling
|
||||
# Get useful and necessary Hub images so we can "docker load" locally instead of pulling
|
||||
COPY contrib/download-frozen-image.sh /go/src/github.com/docker/docker/contrib/
|
||||
RUN ./contrib/download-frozen-image.sh /docker-busybox busybox@4986bf8c15363d1c5d15512d5266f8777bfba4974ac56e3270e7760f6f0a8125
|
||||
RUN ./contrib/download-frozen-image.sh /docker-frozen-images \
|
||||
busybox:latest@4986bf8c15363d1c5d15512d5266f8777bfba4974ac56e3270e7760f6f0a8125
|
||||
# see also "hack/make/.ensure-frozen-images" (which needs to be updated any time this list is)
|
||||
|
||||
# Install man page generator
|
||||
COPY vendor /go/src/github.com/docker/docker/vendor
|
||||
|
|
|
@ -60,7 +60,7 @@ while [ $# -gt 0 ]; do
|
|||
mkdir -p "$dir/$imageId"
|
||||
echo '1.0' > "$dir/$imageId/VERSION"
|
||||
|
||||
curl -sSL -H "Authorization: Token $token" "https://registry-1.docker.io/v1/images/$imageId/json" -o "$dir/$imageId/json" -C -
|
||||
curl -sSL -H "Authorization: Token $token" "https://registry-1.docker.io/v1/images/$imageId/json" -o "$dir/$imageId/json"
|
||||
|
||||
# TODO figure out why "-C -" doesn't work here
|
||||
# "curl: (33) HTTP server doesn't seem to support byte ranges. Cannot resume."
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
if ! docker inspect busybox &> /dev/null; then
|
||||
hardCodedDir='/docker-busybox'
|
||||
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/busybox"
|
||||
# extract the exact "download-frozen-image.sh" line from the Dockerfile itself for consistency
|
||||
awk '$1 == "RUN" && $2 == "./contrib/download-frozen-image.sh" && /busybox@/ {
|
||||
for (i = 2; i < NF; i++)
|
||||
printf ( $i == "'"$hardCodedDir"'" ? "'"$dir"'" : $i ) " ";
|
||||
print $NF;
|
||||
}' Dockerfile | sh -x
|
||||
( set -x; tar -cC "$dir" . | docker load )
|
||||
else
|
||||
( set -x; docker pull busybox )
|
||||
fi
|
||||
fi
|
42
project/make/.ensure-frozen-images
Normal file
42
project/make/.ensure-frozen-images
Normal file
|
@ -0,0 +1,42 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# this list should match roughly what's in the Dockerfile (minus the explicit image IDs, of course)
|
||||
images=(
|
||||
busybox: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
|
|
@ -16,7 +16,7 @@ bundle_test_integration_cli() {
|
|||
# even and especially on test failures
|
||||
didFail=
|
||||
if ! {
|
||||
source "$(dirname "$BASH_SOURCE")/.ensure-busybox"
|
||||
source "$(dirname "$BASH_SOURCE")/.ensure-frozen-images"
|
||||
source "$(dirname "$BASH_SOURCE")/.ensure-httpserver"
|
||||
source "$(dirname "$BASH_SOURCE")/.ensure-emptyfs"
|
||||
|
||||
|
|
Loading…
Reference in a new issue