Просмотр исходного кода

Detect if base image uses buildpack-deps

William Blankenship 10 лет назад
Родитель
Сommit
78d6ca1359
1 измененных файлов с 12 добавлено и 6 удалено
  1. 12 6
      .template-helpers/variant.sh

+ 12 - 6
.template-helpers/variant.sh

@@ -9,9 +9,10 @@ if [ -z "$repo" ]; then
 fi
 
 dir="$(dirname "$(readlink -f "$BASH_SOURCE")")"
+url='https://raw.githubusercontent.com/docker-library/official-images/master/library/'"$repo" 
 
 IFS=$'\n'
-tags=( $(curl -sSL 'https://raw.githubusercontent.com/docker-library/official-images/master/library/'"$repo" | grep -vE '^$|^#' | cut -d':' -f1 | sort -u) )
+tags=( $(curl -sSL $url | grep -vE '^$|^#' | cut -d':' -f1 | sort -u) )
 unset IFS
 
 text=
@@ -23,9 +24,14 @@ for tag in "${tags[@]}"; do
 	fi
 done
 if [ "$text" ]; then
-	# give a little space
-	echo
-	echo
-	cat "$dir/variant.md"
-	echo "$text"
+  latest=($(curl -sSL $url | sed -e 's/git:\/\/github.com\///' -e 's/@/ /' - | grep "latest"))
+  dockerfile='https://raw.githubusercontent.com/'"${latest[1]}"'/'"${latest[2]}"'/'"${latest[3]}"'/Dockerfile'
+  base_image=$(curl -sSL $dockerfile | sed 's/:/\t/' | nawk '/^FROM .*$/ { print $2 }')
+  if [ "$base_image" = "buildpack-deps" ]; then
+    # give a little space
+    echo
+    echo
+    cat "$dir/variant.md"
+    echo "$text"
+  fi
 fi