Skip to content

Commit 964cc2e

Browse files
committed
CBD-4012: Do not pull aliases in couchbase-k8s-microservice-docker
Change-Id: I9b269bde050fff32790daed44d8490d6927904f2 Reviewed-on: http://review.couchbase.org/c/build-tools/+/149857 Reviewed-by: Chris Hillery <[email protected]> Tested-by: Blair Watt <[email protected]>
1 parent 7acb77e commit 964cc2e

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

k8s-microservice/jenkins/util/update-base.sh

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,27 @@
22

33
DOCKERFILE=$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

0 commit comments

Comments
 (0)