From 9f48a0262dad3c357c52b10b09f59c11c65b9b43 Mon Sep 17 00:00:00 2001 From: Arnstein Ressem Date: Tue, 27 Aug 2024 07:30:02 +0200 Subject: [PATCH] Exit early if container image exists --- .../release-generic-container-image.sh | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/screwdriver/release-generic-container-image.sh b/screwdriver/release-generic-container-image.sh index 597cc5926426..d996dc279c4c 100755 --- a/screwdriver/release-generic-container-image.sh +++ b/screwdriver/release-generic-container-image.sh @@ -9,6 +9,12 @@ if [[ $# -ne 1 ]]; then fi readonly VESPA_VERSION=$1 +readonly IMAGE_NAME="vespaengine/vespa-generic-intel-x86_64" + +if curl -fsSL https://hub.docker.com/v2/repositories/$IMAGE_NAME/tags/$VESPA_VERSION/ &> /dev/null; then + echo "Container image docker.io/$IMAGE_NAME:$VESPA_VERSION aldready exists." + exit 0 +fi TMPDIR=$(mktemp -d) trap "rm -rf $TMPDIR" EXIT @@ -38,7 +44,6 @@ RUN --mount=type=bind,target=/rpms/,source=. dnf reinstall -y /rpms/vespa*rpm && USER vespa EOF -readonly IMAGE_NAME="vespaengine/vespa-generic-intel-x86_64" docker build --progress plain \ --build-arg VESPA_VERSION=$VESPA_VERSION \ @@ -49,14 +54,10 @@ docker build --progress plain \ vespa/screwdriver/test-quick-start-guide.sh -if curl -fsSL https://hub.docker.com/v2/repositories/$IMAGE_NAME/tags/$VESPA_VERSION/ &> /dev/null; then - echo "Container image docker.io/$IMAGE_NAME:$VESPA_VERSION aldready exists." -else - OPT_STATE="$(set +o)" - set +x - docker login --username aressem --password "$DOCKER_HUB_DEPLOY_TOKEN" - eval "$OPT_STATE" - docker push docker.io/$IMAGE_NAME:$VESPA_VERSION - docker push docker.io/$IMAGE_NAME:latest -fi +OPT_STATE="$(set +o)" +set +x +docker login --username aressem --password "$DOCKER_HUB_DEPLOY_TOKEN" +eval "$OPT_STATE" +docker push docker.io/$IMAGE_NAME:$VESPA_VERSION +docker push docker.io/$IMAGE_NAME:latest