From 0bb466c3804e33c1b6254b48ef5436a477f8e404 Mon Sep 17 00:00:00 2001 From: Davlet Panech Date: Thu, 17 Mar 2022 17:55:31 -0400 Subject: [PATCH] build images: option to avoid pulling base image build-stx-images.sh executes "docker pull $BASE_IMAGE" unconditionally, overwriting any local image with the same name:tag. Add an option to avoid this. Story: 2009897 Task: 44804 TESTS ----- Build a local base image, then build a derived image with the "-N" option and make sure base image didn't get overwritten during the build. Signed-off-by: Davlet Panech Change-Id: I2ed9748984bd9dc2198ef74c142ccb30eb7d067e --- .../build-docker-images/build-stx-images.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/build-tools/build-docker-images/build-stx-images.sh b/build-tools/build-docker-images/build-stx-images.sh index 9af4fb6e..53f1176b 100755 --- a/build-tools/build-docker-images/build-stx-images.sh +++ b/build-tools/build-docker-images/build-stx-images.sh @@ -31,6 +31,7 @@ HTTPS_PROXY="" NO_PROXY="" DOCKER_USER=${USER} DOCKER_REGISTRY= +PULL_BASE=yes BASE= WHEELS= WHEELS_PY2= @@ -53,6 +54,9 @@ Options: --version: Specify version for output image --stream: Build stream, stable or dev (default: stable) --base: Specify base docker image (required option) + -N,--no-pull-base: Don't pull base image before building; this will use + your local base image if one exists, without overwriting + it by "docker pull" --wheels: Specify path to wheels tarball or image, URL or docker tag (required when building loci projects) --wheels-py2: Use this wheels tarball for Python2 projects @@ -692,7 +696,7 @@ function build_image { esac } -OPTS=$(getopt -o h -l help,os:,version:,release:,stream:,push,http_proxy:,https_proxy:,no_proxy:,user:,registry:,base:,wheels:,wheels-alternate:,wheels-py2:,only:,skip:,prefix:,latest,latest-prefix:,clean,attempts: -- "$@") +OPTS=$(getopt -o hN -l help,os:,version:,release:,stream:,push,http_proxy:,https_proxy:,no_proxy:,user:,registry:,base:,wheels:,wheels-alternate:,wheels-py2:,only:,skip:,prefix:,latest,latest-prefix:,clean,attempts:,no-pull-base -- "$@") if [ $? -ne 0 ]; then usage exit 1 @@ -790,6 +794,10 @@ while true; do MAX_ATTEMPTS=$2 shift 2 ;; + -N|--no-pull-base) + PULL_BASE=no + shift + ;; -h | --help ) usage exit 1 @@ -933,7 +941,9 @@ docker images --format '{{.Repository}}:{{.Tag}}' ${BASE} | grep -q "^${BASE}$" BASE_IMAGE_PRESENT=$? # Pull the image anyway, to ensure it's up to date -docker pull ${BASE} +if [[ "$PULL_BASE" == "yes" ]] ; then + docker pull ${BASE} +fi # Download loci, if needed. get_loci