|
|
@@ -1,5 +1,5 @@
|
|
|
#!/bin/bash
|
|
|
-set -eo pipefail
|
|
|
+set -e
|
|
|
|
|
|
repo="$1"
|
|
|
if [ -z "$repo" ]; then
|
|
|
@@ -8,67 +8,6 @@ if [ -z "$repo" ]; then
|
|
|
exit 1
|
|
|
fi
|
|
|
|
|
|
-IFS=$'\n'
|
|
|
-lines=( $(curl -fsSL 'https://raw.githubusercontent.com/docker-library/official-images/master/library/'"$repo" | grep -vE '^$|^#') )
|
|
|
-unset IFS
|
|
|
-
|
|
|
-if [ "${#lines[@]}" -eq 0 ]; then
|
|
|
- echo >&2 "Failed to read manifest file for $repo"
|
|
|
- exit 1
|
|
|
-fi
|
|
|
-
|
|
|
-repoDirs=()
|
|
|
-declare -A repoDirTags=()
|
|
|
-
|
|
|
-latest=
|
|
|
-uniqImages=()
|
|
|
-for line in "${lines[@]}"; do
|
|
|
- tag="$(echo "$line" | awk -F ': +' '{ print $1 }')"
|
|
|
- if [ -z "$latest" -o "$tag" = 'latest' ]; then
|
|
|
- latest="$tag"
|
|
|
- fi
|
|
|
- repoDir="$(echo "$line" | awk -F ': +' '{ print $2 }')"
|
|
|
- if [ -z "${repoDirTags[$repoDir]}" ]; then
|
|
|
- repoDirs+=( "$repoDir" )
|
|
|
- uniqImages+=( "$repo:$tag" )
|
|
|
- else
|
|
|
- repoDirTags["$repoDir"]+=', '
|
|
|
- fi
|
|
|
- repoDirTags["$repoDir"]+='`'"$tag"'`'
|
|
|
-done
|
|
|
-
|
|
|
-IFS=','
|
|
|
-imageLayers="https://imagelayers.io/?images=${uniqImages[*]}"
|
|
|
-unset IFS
|
|
|
-
|
|
|
-for repoDir in "${repoDirs[@]}"; do
|
|
|
- if [[ "$repoDir" != *github.com* ]]; then
|
|
|
- # skip non-github.com for now
|
|
|
- continue
|
|
|
- fi
|
|
|
-
|
|
|
- # split out some data
|
|
|
- gitUrl="${repoDir%%@*}"
|
|
|
- commitDir="${repoDir#*@}"
|
|
|
- commit="${commitDir%% *}"
|
|
|
- dir="${commitDir#* }"
|
|
|
- if [ "$dir" = "$commitDir" ]; then
|
|
|
- dir=''
|
|
|
- fi
|
|
|
-
|
|
|
- # sanitize some data
|
|
|
- gitUrl="${gitUrl#git://}"
|
|
|
- gitUrl="${gitUrl%/}"
|
|
|
- gitUrl="${gitUrl%.git}"
|
|
|
- dir="${dir#/}"
|
|
|
- dir="${dir%/}"
|
|
|
- [ -z "$dir" ] || dir="$dir/"
|
|
|
-
|
|
|
- url="https://$gitUrl/blob/$commit/${dir}Dockerfile"
|
|
|
-
|
|
|
- echo $'-\t['"${repoDirTags["$repoDir"]}"' (*'"${dir}Dockerfile"'*)]('"$url"')'
|
|
|
-done
|
|
|
-
|
|
|
-echo
|
|
|
-echo "[]($imageLayers)"
|
|
|
-echo
|
|
|
+bashbrew cat \
|
|
|
+ -F "$(dirname "$BASH_SOURCE")/$(basename "$BASH_SOURCE" .sh).tmpl" \
|
|
|
+ "https://github.com/docker-library/official-images/raw/master/library/$repo"
|