From 18e34fe5507819482d4e717aee320873b3d59e22 Mon Sep 17 00:00:00 2001 From: Anuraag Agrawal Date: Sat, 19 Oct 2019 16:59:29 +0900 Subject: [PATCH] Allow the built tag to be prefixed with docker- which can be used to rebuild images without Zipkin server --- .travis.yml | 7 +++++-- docker/hooks/build | 44 ++++++++++++++++++++++++++++++++++++++--- docker/hooks/post_build | 42 --------------------------------------- 3 files changed, 46 insertions(+), 47 deletions(-) delete mode 100755 docker/hooks/post_build diff --git a/.travis.yml b/.travis.yml index ed5219746d8..50f2b69de18 100755 --- a/.travis.yml +++ b/.travis.yml @@ -41,11 +41,14 @@ before_install: install: ./mvnw install -DskipTests=true -Dlicense.skip=true -Dmaven.javadoc.skip=true -B -V script: ./travis/publish.sh -# Don't build release tags. This avoids publish conflicts because the version commit exists both on master and the release tag. -# See https://github.com/travis-ci/travis-ci/issues/1532 branches: except: + # Don't build release tags. This avoids publish conflicts because the version commit exists both on master and the release tag. + # See https://github.com/travis-ci/travis-ci/issues/1532 - /^[0-9]/ + # Don't build docker- tags with Travis. Docker Hub will pick up and run the build. docker- tags are used to recreate + # docker images without rebuilding Zipkin so we don't need to run here. + - /^docker-/ notifications: webhooks: diff --git a/docker/hooks/build b/docker/hooks/build index baada6ed5a0..623e31ccb3e 100755 --- a/docker/hooks/build +++ b/docker/hooks/build @@ -9,11 +9,49 @@ set -v # to top level. cd .. -# SOURCE_BRANCH contains the name of the branch or tag being built. Our build of the master branch -# ignores this argument, while our build of release tags uses it to fetch the right release artifact. -docker build --build-arg version="$SOURCE_BRANCH" -f "$DOCKERFILE_PATH" -t "$IMAGE_NAME" . +# SOURCE_BRANCH is something like +# +# master - Building the master branch. This cut command will return 'master', and Dockerfiles will ignore it +# 1.0.1 - Building a release image along with a new Zipkin server version. This cut command will return +# '1.0.1' and Dockerfiles will use it to fetch the correct version of Zipkin. +# docker-1.0.1 - Building a release image, but not a new Zipkin server. This cut command will return +# '1.0.1' and Dockerfiles will use it to fetch the correct version of Zipkin. +VERSION=$(echo "$SOURCE_BRANCH" | cut -d '-' -f 2) +echo "Building images for version $VERSION" + +docker build --build-arg version="$VERSION" -f "$DOCKERFILE_PATH" -t "$IMAGE_NAME" . IFS=',' read -ra TAGS <<< "$DOCKER_TAG" for tag in ${TAGS[@]}; do docker tag "$IMAGE_NAME" "${DOCKER_REPO}:${tag}" done + +# We always build zipkin-slim +echo Building zipkin-slim +docker build --build-arg version="$VERSION" -f "$DOCKERFILE_PATH" -t "openzipkin/zipkin-slim:${TAGS[0]}" --target zipkin-slim . +for tag in ${TAGS[@]:1}; do + docker tag "openzipkin/zipkin-slim:${TAGS[0]}" "openzipkin/zipkin-slim:$tag" +done + +# We always build test images formerly hosted on https://github.com/openzipkin/docker-zipkin +echo Building zipkin-ui +docker build --build-arg version="VERSION" -f "$DOCKERFILE_PATH" -t "openzipkin/zipkin-ui:${TAGS[0]}" --target zipkin-ui . +for tag in ${TAGS[@]:1}; do + docker tag "openzipkin/zipkin-ui:${TAGS[0]}" "openzipkin/zipkin-ui:$tag" +done + +# We also build testing images to correspond with the server version to keep schemas up to date +for path in collector/kafka storage/cassandra storage/elasticsearch6 storage/elasticsearch7 storage/mysql; do + image=zipkin-$(basename ${path}) + echo Building ${image} + docker build --build-arg version="$VERSION" -f "docker/${path}/Dockerfile" -t "openzipkin/${image}:${TAGS[0]}" . + for tag in ${TAGS[@]:1}; do + docker tag "openzipkin/${image}:${TAGS[0]}" "openzipkin/${image}:$tag" + done +done + +if [[ "$DOCKER_TAG" == "master" ]]; then + # We rebuild the builder image on master push, not on release pushes. + echo Building zipkin-builder + docker build -f "$DOCKERFILE_PATH" -t openzipkin/zipkin-builder --target zipkin-builder . +fi diff --git a/docker/hooks/post_build b/docker/hooks/post_build deleted file mode 100755 index 731ce09cc10..00000000000 --- a/docker/hooks/post_build +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash - -set -v - -# This hook is called with the current directory set to the same as the Dockerfile, so we go back -# to top level. -cd .. - -IFS=',' read -ra TAGS <<< "$DOCKER_TAG" - -# We always build zipkin-slim -echo Building zipkin-slim -docker build --build-arg version="$SOURCE_BRANCH" -f "$DOCKERFILE_PATH" -t "openzipkin/zipkin-slim:${TAGS[0]}" --target zipkin-slim . -for tag in ${TAGS[@]:1}; do - docker tag "openzipkin/zipkin-slim:${TAGS[0]}" "openzipkin/zipkin-slim:$tag" -done - -# We always build test images formerly hosted on openzipkin/docker-zipkin -# SOURCE_BRANCH contains the name of the branch or tag being built. Our build of the master branch -# ignores this argument, while our build of release tags uses it to fetch the right release artifact. - -echo Building zipkin-ui -docker build --build-arg version="$SOURCE_BRANCH" -f "$DOCKERFILE_PATH" -t "openzipkin/zipkin-ui:${TAGS[0]}" --target zipkin-ui . -for tag in ${TAGS[@]:1}; do - docker tag "openzipkin/zipkin-ui:${TAGS[0]}" "openzipkin/zipkin-ui:$tag" -done - -# We also build testing images to correspond with the server version to keep schemas up to date -for path in collector/kafka storage/cassandra storage/elasticsearch6 storage/elasticsearch7 storage/mysql; do - image=zipkin-$(basename ${path}) - echo Building ${image} - docker build --build-arg version="$SOURCE_BRANCH" -f "docker/${path}/Dockerfile" -t "openzipkin/${image}:${TAGS[0]}" . - for tag in ${TAGS[@]:1}; do - docker tag "openzipkin/${image}:${TAGS[0]}" "openzipkin/${image}:$tag" - done -done - -if [[ "$DOCKER_TAG" == "master" ]]; then - # We rebuild the builder image on master push, not on release pushes. - echo Building zipkin-builder - docker build -f "$DOCKERFILE_PATH" -t openzipkin/zipkin-builder --target zipkin-builder . -fi