Add blurb for "*-stretch" and "*-xenial" tags; Improve variant detection for "windowsservercore-zzz" tags

This commit is contained in:
Joe Ferguson 2018-10-11 13:19:26 -07:00
parent 8349715102
commit 8e97f59d42
5 changed files with 106 additions and 27 deletions

View File

@ -1,7 +0,0 @@
# Image Variants
The `%%IMAGE%%` images come in many flavors, each designed for a specific use case.
## `%%IMAGE%%:<version>`
This is the defacto image. If you are unsure about what your needs are, you probably want to use this one. It is designed to be used both as a throw away container (mount your source code and start the container to start your app), as well as the base to build other images off of. This tag is based off of [`buildpack-deps`](https://registry.hub.docker.com/_/buildpack-deps/). `buildpack-deps` is designed for the average user of docker who has many images on their system. It, by design, has a large number of extremely common Debian packages. This reduces the number of packages that images that derive from it need to install, thus reducing the overall size of all images on your system.

View File

@ -0,0 +1 @@
This tag is based off of [`buildpack-deps`](https://registry.hub.docker.com/_/buildpack-deps/). `buildpack-deps` is designed for the average user of docker who has many images on their system. It, by design, has a large number of extremely common Debian packages. This reduces the number of packages that images that derive from it need to install, thus reducing the overall size of all images on your system.

View File

@ -0,0 +1 @@
Some of these tags may have names like %%DEB-SUITES%% in them. These are the suite code names for releases of [Debian](https://wiki.debian.org/DebianReleases) and indicate which release the image is based on.

View File

@ -0,0 +1 @@
Some of these tags may have names like %%DEB-SUITES%% in them. These are the suite code names for releases of [Ubuntu](https://wiki.ubuntu.com/Releases) and indicate which release the image is based on.

View File

@ -11,11 +11,59 @@ fi
dir="$(dirname "$(readlink -f "$BASH_SOURCE")")"
repoDir="$dir/../$repo"
# if we haven't set BASHBREW_LIBRARY explicitly (like Jenkins does, for example), don't trust the local library
if [ -z "${BASHBREW_LIBRARY:-}" ]; then
repo="https://github.com/docker-library/official-images/raw/master/library/$repo"
fi
# prints "$2$1$3$1...$N"
join() {
local sep="$1"; shift
local out; printf -v out "${sep//%/%%}%s" "$@"
echo "${out#$sep}"
}
commaJoin() {
local items=( $(xargs -n1 <<<"$1" | sort -u) ); shift
sep=', '
case "${#items[@]}" in
0)
return
;;
1)
echo "$items"
return
;;
2)
sep=' '
;;
esac
items[-1]="or ${items[-1]}"
join "$sep" "${items[@]}"
}
tagFiles() {
local tag="$1"; shift
local tagUltimate="${tag##*-}" # 3.6-stretch -> stretch
local tagPenultimate="${tag%-*}" # 2.7.15-windowsservercore-1803 -> 2.7.15-windowsservercore
tagPenultimate="${tagPenultimate##*-}" # 2.7.15-windowsservercore -> windowsservercore
echo \
"$repoDir/variant-$tag.md" \
"$repoDir/variant-$tagUltimate.md" \
"$repoDir/variant-$tagPenultimate.md" \
"$dir/variant-$tag.md" \
"$dir/variant-$tagUltimate.md" \
"$dir/variant-$tagPenultimate.md"
}
_repo() {
local repo=$1; shift
# if we haven't set BASHBREW_LIBRARY explicitly (like Jenkins does, for example), don't trust the local library
if [ -z "${BASHBREW_LIBRARY:-}" ]; then
repo="https://github.com/docker-library/official-images/raw/master/library/$repo"
fi
echo "$repo"
}
bbRepo="$(_repo "$repo")"
IFS=$'\n'
tags=( $(bashbrew cat -f '
{{- $archSpecific := getenv "ARCH_SPECIFIC_DOCS" -}}
@ -24,16 +72,13 @@ tags=( $(bashbrew cat -f '
{{- join "\n" .Tags -}}
{{- "\n" -}}
{{- end -}}
' "$repo") )
' "$bbRepo") )
unset IFS
text=
declare -A includedFiles=()
for tag in "${tags[@]}"; do
for f in \
"$repoDir/variant-$tag.md" "$repoDir/variant-${tag##*-}.md" \
"$dir/variant-$tag.md" "$dir/variant-${tag##*-}.md" \
; do
for f in $(tagFiles "$tag"); do
if [ -n "${includedFiles[$f]}" ]; then
# make sure we don't duplicate variant sections
break
@ -52,25 +97,63 @@ for tag in "${tags[@]}"; do
done
if [ "$text" ]; then
buildpacks=
potentialTags="$(bashbrew list --uniq "$repo" | cut -d: -f2)"
default="$([ -f "$repoDir/variant.md" ] && cat "$repoDir/variant.md" || cat "$dir/variant.md")"
default+=$'\n' # parameter expansion eats the trailing newline
# buildpack-deps text
potentialTags="$(bashbrew list --uniq "$bbRepo" | cut -d: -f2)"
for tag in $potentialTags; do
baseImage="$(bashbrew cat -f '{{ .ArchDockerFrom (.TagEntry.Architectures | first) .TagEntry }}' "$repo:$tag")"
baseImage="$(bashbrew cat -f '{{ .ArchDockerFrom (.TagEntry.Architectures | first) .TagEntry }}' "$bbRepo:$tag")"
case "$baseImage" in
buildpack-deps:*-*) ;; # "scm", "curl" -- not large images
buildpack-deps:*) buildpacks=1; break ;;
buildpack-deps:*)
default+=$'\n' # give a little space
default+="$(< "$dir/variant-default-buildpack-deps.md")"
default+=$'\n' # parameter expansion eats the trailing newline
break
;;
esac
done
echo
echo
if [ "$repo" != 'debian' ] && [ "$repo" != 'ubuntu' ]; then
# what is 'jessie', 'stretch' and 'sid'
# https://github.com/docker-library/python/issues/343
debian=( $(bashbrew list --uniq "$(_repo 'debian')" | grep -vE 'stable|slim|backports|experimental' | cut -d: -f2) )
ubuntu=( $(bashbrew list "$(_repo 'ubuntu')" | grep -vE 'devel|latest|[0-9]' | cut -d: -f2) )
foundDebianTags=
foundUbuntuTags=
for tag in ${tags[@]}; do
for suite in "${debian[@]}"; do
case "$tag" in
*-"$suite" | "$suite"-* | *-"$suite"-* | "$suite" )
foundDebianTags+=" $suite"
;;
esac
done
for suite in "${ubuntu[@]}"; do
case "$tag" in
*-"$suite" | "$suite"-* | *-"$suite"-* | "$suite" )
foundUbuntuTags+=" $suite"
;;
esac
done
done
if [ -n "$buildpacks" ]; then
f='variant-buildpacks.md'
else
f='variant.md'
if [ -n "$foundDebianTags" ]; then
default+=$'\n' # give a little space
default+="$( sed -e 's/%%DEB-SUITES%%/'"$(commaJoin "$foundDebianTags")"'/' "$dir/variant-default-debian.md" )"
default+=$'\n' # parameter expansion eats the trailing newline
fi
if [ -n "$foundUbuntuTags" ]; then
default+=$'\n' # give a little space
default+="$( sed -e 's/%%DEB-SUITES%%/'"$(commaJoin "$foundUbuntuTags")"'/' "$dir/variant-default-ubuntu.md" )"
default+=$'\n' # parameter expansion eats the trailing newline
fi
fi
[ -f "$repoDir/$f" ] && cat "$repoDir/$f" || cat "$dir/$f"
echo
echo
echo -n "$default"
echo "$text"
fi