File tree Expand file tree Collapse file tree 1 file changed +24
-9
lines changed
k8s-microservice/jenkins/util Expand file tree Collapse file tree 1 file changed +24
-9
lines changed Original file line number Diff line number Diff line change 22
33DOCKERFILE=$1
44
5- # Find the last FROM line in the Dockerfile and cut off the image name
6- base=$( tac ${DOCKERFILE} | grep -m1 ' ^FROM' | cut -d' ' -f2)
7-
8- if [ " ${base} " = " scratch" ]; then
9- echo " Not updating 'scratch' base image"
10- else
11- echo " Updating base image ${base} "
12- docker pull ${base}
13- fi
5+ upstream_images=()
6+ aliases=()
7+
8+ # Get list of images and their aliases
9+ while read line; do
10+ if $( echo $line | grep -q " ^FROM" ) ; then
11+ upstream_images+=($( echo $line | awk ' {print $2}' ) )
12+ if $( echo $line | grep -q " as " ) ; then
13+ aliases+=($( echo $line | sed " s/.* as //" ) )
14+ fi
15+ fi
16+ done < $DOCKERFILE
17+
18+ # Pull all non-alias images listed in FROM instructions
19+ for image in " ${upstream_images[@]} " ; do
20+ if [[ ! " ${aliases[@]} " =~ " ${image} " ]]; then
21+ if [ " ${image} " = " scratch" ]; then
22+ echo " Not updating 'scratch' base image"
23+ else
24+ echo " Updating base image ${image} "
25+ docker pull ${image}
26+ fi
27+ fi
28+ done
You can’t perform that action at this time.
0 commit comments