-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <[email protected]>
- Loading branch information
Showing
5 changed files
with
48 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters