Skip to content

Commit

Permalink
Handle multiple tags in hooks.
Browse files Browse the repository at this point in the history
  • Loading branch information
anuraaga committed Oct 9, 2019
1 parent e64556b commit 13b8d4a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
7 changes: 7 additions & 0 deletions docker/hooks/build
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

set -v

# Docker Hub's default build command seems to not handle .dockerignore correctly. Doing a simple build command
# ourselves works fine.

Expand All @@ -8,3 +10,8 @@
cd ..

docker build -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
10 changes: 8 additions & 2 deletions docker/hooks/post_build
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
#!/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 ..

# We always build an image containing nginx and zipkin-lens in addition to the default image of zipkin-server
echo Building zipkin-ui
docker build -f $DOCKERFILE_PATH -t openzipkin/zipkin-ui:$DOCKER_TAG --target zipkin-ui .
IFS=',' read -ra TAGS <<< "$DOCKER_TAG"
docker build -f "$DOCKERFILE_PATH" -t "anuraaga/docker-hub-test-2:${TAGS[0]}" --target zipkin-ui .
for tag in ${TAGS[@]:1}; do
docker tag "anuraaga/docker-hub-test-2:${TAGS[0]}" "anuraaga/docker-hub-test-2:$tag"
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 .
docker build -f "$DOCKERFILE_PATH" -t anuraaga/docker-hub-test-3 --target zipkin-builder .
fi
11 changes: 8 additions & 3 deletions docker/hooks/post_push
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
#!/bin/bash

if [[ "$DOCKER_REPO" == "index.docker.io/openzipkin/zipkin" ]]; then
set -v

if [[ "$DOCKER_REPO" == "index.docker.io/anuraaga/docker-hub-test" ]]; then
# We always push an image containing nginx and zipkin-lens in addition to the default image of zipkin-server
echo Pushing zipkin-ui
docker push openzipkin/zipkin-ui:$DOCKER_TAG
IFS=',' read -ra TAGS <<< "$DOCKER_TAG"
for tag in ${TAGS[@]}; do
docker push "anuraaga/docker-hub-test-2:$tag"
done

if [[ "$DOCKER_TAG" == "master" ]]; then
# We repush the builder image on master push, not on release pushes.
echo Pushing zipkin-builder
# zipkin-builder is just a cache of maven / npm dependencies, there's no need to version it
# with docker tags.
docker push openzipkin/zipkin-builder
docker push anuraaga/docker-hub-test-3
fi
fi

0 comments on commit 13b8d4a

Please sign in to comment.