From 346e36f52b9ba85611d3860bdfb5c200a2635aa3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Carranza=20V=C3=A9lez?= Date: Thu, 10 Sep 2015 14:24:26 +0000 Subject: [PATCH] Add a script to retry docker push when deploying --- .dockerignore | 1 + Makefile | 2 +- retry_docker_push.sh | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100755 retry_docker_push.sh diff --git a/.dockerignore b/.dockerignore index 56818f1a..6fbeb947 100644 --- a/.dockerignore +++ b/.dockerignore @@ -10,3 +10,4 @@ automation tools README.md gosuper +retry_docker_push.sh diff --git a/Makefile b/Makefile index 00c91451..1eaea8aa 100644 --- a/Makefile +++ b/Makefile @@ -50,7 +50,7 @@ supervisor: gosuper deploy: supervisor docker tag -f $(IMAGE) $(DEPLOY_REGISTRY)$(IMAGE) - docker push $(DEPLOY_REGISTRY)$(IMAGE) + bash retry_docker_push.sh $(DEPLOY_REGISTRY)$(IMAGE) go-builder: -cp tools/dind/config.json ./gosuper/ diff --git a/retry_docker_push.sh b/retry_docker_push.sh new file mode 100755 index 00000000..863747d5 --- /dev/null +++ b/retry_docker_push.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +IMAGE=$1 +retries=0 + +while [ $retries -lt 3 ]; do + let retries=retries+1 + docker push $IMAGE + ret=$? + if [ "$ret" -eq "0" ]; then + break + fi +done + +exit $ret