add docker-image-tag target to Makefile

This commit is contained in:
Adam Babik 2018-02-12 21:56:53 +01:00 committed by Frank Mueller
parent ffef611295
commit 9ed2663b6e
2 changed files with 18 additions and 1 deletions

View File

@ -72,7 +72,11 @@ statusgo-library: ##@cross-compile Build status-go as static library for current
docker-image: ##@docker Build docker image (use DOCKER_IMAGE_NAME to set the image name) docker-image: ##@docker Build docker image (use DOCKER_IMAGE_NAME to set the image name)
@echo "Building docker image..." @echo "Building docker image..."
docker build --file _assets/build/Dockerfile --build-arg "build_tags=$(BUILD_TAGS)" . -t $(DOCKER_IMAGE_NAME) docker build --file _assets/build/Dockerfile --build-arg "build_tags=$(BUILD_TAGS)" . -t $(DOCKER_IMAGE_NAME):latest
docker-image-tag: ##@docker Tag DOCKER_IMAGE_NAME:latest with a tag following pattern $GIT_SHA[:8]-$BUILD_TAGS
@echo "Tagging docker image..."
docker tag $(DOCKER_IMAGE_NAME):latest $(DOCKER_IMAGE_NAME):$(shell BUILD_TAGS="$(BUILD_TAGS)" ./_assets/ci/get-docker-image-tag.sh)
xgo-docker-images: ##@docker Build xgo docker images xgo-docker-images: ##@docker Build xgo docker images
@echo "Building xgo docker images..." @echo "Building xgo docker images..."

View File

@ -0,0 +1,13 @@
#!/usr/bin/env bash
#
# Description
set -e -o pipefail
tag="$(git rev-parse HEAD | cut -c 1-8)"
if [ ! -z "$BUILD_TAGS" ]; then
tag="$tag-$(echo $BUILD_TAGS | sed -e "s/[[:space:]]/-/g")"
fi
echo $tag