Skip to content

Commit

Permalink
Exit early if container image exists
Browse files Browse the repository at this point in the history
  • Loading branch information
aressem committed Aug 27, 2024
1 parent 907bb4c commit 9f48a02
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions screwdriver/release-generic-container-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 \
Expand All @@ -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

0 comments on commit 9f48a02

Please sign in to comment.