<p>osmith has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/13848">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">Add retries for downloading debian "Release" file<br><br>Use wget to download the "Release" file outside of the Dockerfile, then<br>add the local file to the docker image, to make docker use its cache if<br>the file did not change.<br><br>Change-Id: Ib7c0ffd1e938349f2e1478d833abd351bc886bed<br>---<br>M .gitignore<br>M debian-jessie-build/Dockerfile<br>M debian-stretch-build/Dockerfile<br>M jenkins-common.sh<br>4 files changed, 31 insertions(+), 2 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/docker-playground refs/changes/48/13848/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/.gitignore b/.gitignore</span><br><span>index a16a1a0..ea885c8 100644</span><br><span>--- a/.gitignore</span><br><span>+++ b/.gitignore</span><br><span>@@ -1 +1,4 @@</span><br><span> .release</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+# See download_debian_repo_release_with_retries() in jenkins-common.sh</span><br><span style="color: hsl(120, 100%, 40%);">+Release</span><br><span>diff --git a/debian-jessie-build/Dockerfile b/debian-jessie-build/Dockerfile</span><br><span>index 29daff6..9d85ec9 100644</span><br><span>--- a/debian-jessie-build/Dockerfile</span><br><span>+++ b/debian-jessie-build/Dockerfile</span><br><span>@@ -2,7 +2,9 @@</span><br><span> </span><br><span> MAINTAINER Harald Welte <laforge@gnumonks.org></span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-ADD http://ftp.debian.org/debian/dists/jessie/Release /tmp/Release</span><br><span style="color: hsl(120, 100%, 40%);">+# See download_debian_repo_release_with_retries() in jenkins-common.sh</span><br><span style="color: hsl(120, 100%, 40%);">+ADD     Release /tmp/Release</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> RUN   apt-get update && \</span><br><span>  apt-get upgrade -y && \</span><br><span>      apt-get install -y --no-install-recommends \</span><br><span>diff --git a/debian-stretch-build/Dockerfile b/debian-stretch-build/Dockerfile</span><br><span>index e262d86..1fc43a9 100644</span><br><span>--- a/debian-stretch-build/Dockerfile</span><br><span>+++ b/debian-stretch-build/Dockerfile</span><br><span>@@ -2,7 +2,9 @@</span><br><span> </span><br><span> MAINTAINER Harald Welte <laforge@gnumonks.org></span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-ADD      http://ftp.debian.org/debian/dists/stretch/Release /tmp/Release</span><br><span style="color: hsl(120, 100%, 40%);">+# See download_debian_repo_release_with_retries() in jenkins-common.sh</span><br><span style="color: hsl(120, 100%, 40%);">+ADD    Release /tmp/Release</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> RUN   apt-get update && \</span><br><span>  apt-get upgrade -y && \</span><br><span>      apt-get install -y --no-install-recommends \</span><br><span>diff --git a/jenkins-common.sh b/jenkins-common.sh</span><br><span>index a703a05..37b574a 100644</span><br><span>--- a/jenkins-common.sh</span><br><span>+++ b/jenkins-common.sh</span><br><span>@@ -2,6 +2,26 @@</span><br><span>     test -n "$(docker images -q "$REPO_USER/$1")"</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+# Have multiple attempts at downloading the "Release" file for the base debian images (debian-*-build), upon which all</span><br><span style="color: hsl(120, 100%, 40%);">+# practically used images in docker-playground.git are based on. We copy that file into the docker image, to let it</span><br><span style="color: hsl(120, 100%, 40%);">+# invalidate the cache after each release. Due to frequent download errors, we need to have the retry functionallity.</span><br><span style="color: hsl(120, 100%, 40%);">+# $1: docker image name (e.g. "debian-stretch-build")</span><br><span style="color: hsl(120, 100%, 40%);">+download_debian_repo_release_with_retries() {</span><br><span style="color: hsl(120, 100%, 40%);">+      local url=""</span><br><span style="color: hsl(120, 100%, 40%);">+        case "$1" in</span><br><span style="color: hsl(120, 100%, 40%);">+                debian-stretch-build)</span><br><span style="color: hsl(120, 100%, 40%);">+                 url="http://ftp.debian.org/debian/dists/stretch/Release"</span><br><span style="color: hsl(120, 100%, 40%);">+                    ;;</span><br><span style="color: hsl(120, 100%, 40%);">+            debian-jessie-build)</span><br><span style="color: hsl(120, 100%, 40%);">+                  url="http://ftp.debian.org/debian/dists/jessie/Release"</span><br><span style="color: hsl(120, 100%, 40%);">+                     ;;</span><br><span style="color: hsl(120, 100%, 40%);">+            *)</span><br><span style="color: hsl(120, 100%, 40%);">+                    return</span><br><span style="color: hsl(120, 100%, 40%);">+                        ;;</span><br><span style="color: hsl(120, 100%, 40%);">+    esac</span><br><span style="color: hsl(120, 100%, 40%);">+  wget --tries=10 "$url" -O "../$1/Release"</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> docker_images_require() {</span><br><span>      local from_line</span><br><span>      local pull_arg</span><br><span>@@ -16,6 +36,8 @@</span><br><span>                           pull_arg=""</span><br><span>                        fi</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+                        download_debian_repo_release_with_retries "$i"</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>                   echo "Building image: $i (export NO_DOCKER_IMAGE_BUILD=1 to prevent this)"</span><br><span>                         PULL="$pull_arg" make -C "../$i" || exit 1</span><br><span>               fi</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/13848">change 13848</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/13848"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: docker-playground </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: Ib7c0ffd1e938349f2e1478d833abd351bc886bed </div>
<div style="display:none"> Gerrit-Change-Number: 13848 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: osmith <osmith@sysmocom.de> </div>