File tree Expand file tree Collapse file tree 10 files changed +74
-10
lines changed Expand file tree Collapse file tree 10 files changed +74
-10
lines changed Original file line number Diff line number Diff line change @@ -21,9 +21,12 @@ set -e
2121
2222cd ` dirname $0 `
2323
24- docker build --no-cache -t $HOST /$ACCOUNT /$REPOSITORY :$VERSION check_style_image
24+ . ./prefetch_docker_image.sh
25+ CONTEXT=check_style_image
26+ prefetch_docker_image $CONTEXT /Dockerfile
27+ docker build --no-cache -t $HOST /$ACCOUNT /$REPOSITORY :$VERSION $CONTEXT
2528# Get a username and password for this by visiting
26- # https://docker.elastic.co:7000 and allowing it to authenticate against your
29+ # https://docker-auth .elastic.co and allowing it to authenticate against your
2730# GitHub account
2831docker login $HOST
2932docker push $HOST /$ACCOUNT /$REPOSITORY :$VERSION
Original file line number Diff line number Diff line change @@ -23,9 +23,12 @@ set -e
2323
2424cd ` dirname $0 `
2525
26- docker build --no-cache -t $HOST /$ACCOUNT /$REPOSITORY :$VERSION linux_aarch64_cross_image
26+ . ./prefetch_docker_image.sh
27+ CONTEXT=linux_aarch64_cross_image
28+ prefetch_docker_image $CONTEXT /Dockerfile
29+ docker build --no-cache -t $HOST /$ACCOUNT /$REPOSITORY :$VERSION $CONTEXT
2730# Get a username and password for this by visiting
28- # https://docker.elastic.co:7000 and allowing it to authenticate against your
31+ # https://docker-auth .elastic.co and allowing it to authenticate against your
2932# GitHub account
3033docker login $HOST
3134docker push $HOST /$ACCOUNT /$REPOSITORY :$VERSION
Original file line number Diff line number Diff line change @@ -29,9 +29,12 @@ set -e
2929
3030cd ` dirname $0 `
3131
32- docker build --no-cache -t $HOST /$ACCOUNT /$REPOSITORY :$VERSION linux_aarch64_native_image
32+ . ./prefetch_docker_image.sh
33+ CONTEXT=linux_aarch64_native_image
34+ prefetch_docker_image $CONTEXT /Dockerfile
35+ docker build --no-cache -t $HOST /$ACCOUNT /$REPOSITORY :$VERSION $CONTEXT
3336# Get a username and password for this by visiting
34- # https://docker.elastic.co:7000 and allowing it to authenticate against your
37+ # https://docker-auth .elastic.co and allowing it to authenticate against your
3538# GitHub account
3639docker login $HOST
3740docker push $HOST /$ACCOUNT /$REPOSITORY :$VERSION
Original file line number Diff line number Diff line change @@ -29,9 +29,12 @@ set -e
2929
3030cd ` dirname $0 `
3131
32- docker build --no-cache -t $HOST /$ACCOUNT /$REPOSITORY :$VERSION linux_image
32+ . ./prefetch_docker_image.sh
33+ CONTEXT=linux_image
34+ prefetch_docker_image $CONTEXT /Dockerfile
35+ docker build --no-cache -t $HOST /$ACCOUNT /$REPOSITORY :$VERSION $CONTEXT
3336# Get a username and password for this by visiting
34- # https://docker.elastic.co:7000 and allowing it to authenticate against your
37+ # https://docker-auth .elastic.co and allowing it to authenticate against your
3538# GitHub account
3639docker login $HOST
3740docker push $HOST /$ACCOUNT /$REPOSITORY :$VERSION
Original file line number Diff line number Diff line change @@ -23,9 +23,12 @@ set -e
2323
2424cd ` dirname $0 `
2525
26- docker build --no-cache -t $HOST /$ACCOUNT /$REPOSITORY :$VERSION macosx_image
26+ . ./prefetch_docker_image.sh
27+ CONTEXT=macosx_image
28+ prefetch_docker_image $CONTEXT /Dockerfile
29+ docker build --no-cache -t $HOST /$ACCOUNT /$REPOSITORY :$VERSION $CONTEXT
2730# Get a username and password for this by visiting
28- # https://docker.elastic.co:7000 and allowing it to authenticate against your
31+ # https://docker-auth .elastic.co and allowing it to authenticate against your
2932# GitHub account
3033docker login $HOST
3134docker push $HOST /$ACCOUNT /$REPOSITORY :$VERSION
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ #
3+ # Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
4+ # or more contributor license agreements. Licensed under the Elastic License;
5+ # you may not use this file except in compliance with the Elastic License.
6+ #
7+
8+ # Pull a docker image, retrying up to 5 times.
9+ #
10+ # Making sure the "FROM" image is present locally before building an image
11+ # based on it removes the risk of a "docker build" failing due to transient
12+ # Docker registry problems.
13+ #
14+ # The argument is the path to the Dockerfile to be built.
15+ function prefetch_docker_image {
16+ DOCKERFILE=" $1 "
17+ IMAGE=$( grep ' ^FROM' " $DOCKERFILE " | awk ' { print $2 }' | head -1)
18+ ATTEMPT=0
19+ MAX_RETRIES=5
20+
21+ while true
22+ do
23+ ATTEMPT=$(( ATTEMPT+ 1 ))
24+
25+ if [ $ATTEMPT -gt $MAX_RETRIES ] ; then
26+ echo " Docker pull retries exceeded, aborting."
27+ exit 1
28+ fi
29+
30+ if docker pull " $IMAGE " ; then
31+ echo " Docker pull of $IMAGE successful."
32+ break
33+ else
34+ echo " Docker pull of $IMAGE unsuccessful, attempt '$ATTEMPT '."
35+ fi
36+ done
37+ }
38+
Original file line number Diff line number Diff line change @@ -62,6 +62,8 @@ cd "$TOOLS_DIR/.."
6262# necessary network access
63633rd_party/pull-eigen.sh
6464
65+ . " $TOOLS_DIR /docker/prefetch_docker_image.sh"
66+
6567for PLATFORM in ` echo $PLATFORMS | tr ' ' ' \n' | sort -u`
6668do
6769
7274 DOCKERFILE=" $TOOLS_DIR /docker/${PLATFORM} _builder/Dockerfile"
7375 TEMP_TAG=` git rev-parse --short=14 HEAD` -$PLATFORM -$$
7476
77+ prefetch_docker_image " $DOCKERFILE "
7578 docker build --no-cache --force-rm -t $TEMP_TAG --build-arg VERSION_QUALIFIER=" $VERSION_QUALIFIER " --build-arg SNAPSHOT=$SNAPSHOT -f " $DOCKERFILE " .
7679 # Using tar to copy the build artifacts out of the container seems more reliable
7780 # than docker cp, and also means the files end up with the correct uid/gid
Original file line number Diff line number Diff line change @@ -26,6 +26,8 @@ cd "$TOOLS_DIR/.."
2626DOCKERFILE=" $TOOLS_DIR /docker/style_checker/Dockerfile"
2727TEMP_TAG=` git rev-parse --short=14 HEAD` -style-$$
2828
29+ . " $TOOLS_DIR /docker/prefetch_docker_image.sh"
30+ prefetch_docker_image " $DOCKERFILE "
2931docker build --no-cache --force-rm -t $TEMP_TAG -f " $DOCKERFILE " .
3032docker run --rm --workdir=/ml-cpp $TEMP_TAG dev-tools/check-style.sh --all
3133RC=$?
Original file line number Diff line number Diff line change @@ -62,6 +62,8 @@ cd "$TOOLS_DIR/.."
6262# necessary network access
63633rd_party/pull-eigen.sh
6464
65+ . " $TOOLS_DIR /docker/prefetch_docker_image.sh"
66+
6567for PLATFORM in ` echo $PLATFORMS | tr ' ' ' \n' | sort -u`
6668do
6769
7375 DOCKERFILE=" $TOOLS_DIR /docker/${PLATFORM} _tester/Dockerfile"
7476 TEMP_TAG=` git rev-parse --short=14 HEAD` -$PLATFORM -$$
7577
78+ prefetch_docker_image " $DOCKERFILE "
7679 docker build --no-cache --force-rm -t $TEMP_TAG --build-arg VERSION_QUALIFIER=" $VERSION_QUALIFIER " --build-arg SNAPSHOT=$SNAPSHOT -f " $DOCKERFILE " .
7780 # Using tar to copy the build and test artifacts out of the container seems
7881 # more reliable than docker cp, and also means the files end up with the
Original file line number Diff line number Diff line change @@ -67,6 +67,9 @@ git repack -a -d
6767readonly GIT_TOPLEVEL=$( git rev-parse --show-toplevel 2> /dev/null)
6868rm -f " ${GIT_TOPLEVEL} /.git/objects/info/alternates"
6969
70+ # The Docker version is helpful to identify version-specific Docker bugs
71+ docker --version
72+
7073# Build and test the native Linux architecture
7174if [ " $HARDWARE_ARCH " = x86_64 ] ; then
7275
You can’t perform that action at this time.
0 commit comments