Make sure all new docker images are also tagged with commit (#1062)
This change also defines new makefile targets which prevent from pushing `latest` image tags by accident.
This commit is contained in:
parent
237aeea7b2
commit
4f9a7a908e
33
Makefile
33
Makefile
|
@ -28,6 +28,9 @@ endif
|
||||||
CGO_CFLAGS=-I/$(JAVA_HOME)/include -I/$(JAVA_HOME)/include/darwin
|
CGO_CFLAGS=-I/$(JAVA_HOME)/include -I/$(JAVA_HOME)/include/darwin
|
||||||
GOBIN=$(dir $(realpath $(firstword $(MAKEFILE_LIST))))build/bin
|
GOBIN=$(dir $(realpath $(firstword $(MAKEFILE_LIST))))build/bin
|
||||||
GIT_COMMIT := $(shell git rev-parse --short HEAD)
|
GIT_COMMIT := $(shell git rev-parse --short HEAD)
|
||||||
|
GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
|
||||||
|
GIT_LOCAL := $(shell git rev-parse @)
|
||||||
|
GIT_REMOTE := $(shell git fetch -q && git rev-parse origin)
|
||||||
|
|
||||||
BUILD_FLAGS ?= $(shell echo "-ldflags '-X main.buildStamp=`date -u '+%Y-%m-%d.%H:%M:%S'` -X github.com/status-im/status-go/params.VersionMeta=$(GIT_COMMIT)'")
|
BUILD_FLAGS ?= $(shell echo "-ldflags '-X main.buildStamp=`date -u '+%Y-%m-%d.%H:%M:%S'` -X github.com/status-im/status-go/params.VersionMeta=$(GIT_COMMIT)'")
|
||||||
|
|
||||||
|
@ -43,6 +46,8 @@ DOCKER_IMAGE_NAME ?= statusteam/status-go
|
||||||
BOOTNODE_IMAGE_NAME ?= statusteam/bootnode
|
BOOTNODE_IMAGE_NAME ?= statusteam/bootnode
|
||||||
STATUSD_PRUNE_IMAGE_NAME ?= statusteam/statusd-prune
|
STATUSD_PRUNE_IMAGE_NAME ?= statusteam/statusd-prune
|
||||||
|
|
||||||
|
DOCKER_IMAGE_CUSTOM_TAG ?= $(shell BUILD_TAGS="$(BUILD_TAGS)" ./_assets/ci/get-docker-image-tag.sh)
|
||||||
|
|
||||||
DOCKER_TEST_WORKDIR = /go/src/github.com/status-im/status-go/
|
DOCKER_TEST_WORKDIR = /go/src/github.com/status-im/status-go/
|
||||||
DOCKER_TEST_IMAGE = golang:1.10
|
DOCKER_TEST_IMAGE = golang:1.10
|
||||||
|
|
||||||
|
@ -129,15 +134,33 @@ 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)" --build-arg "build_flags=$(BUILD_FLAGS)" . -t $(DOCKER_IMAGE_NAME):latest
|
docker build --file _assets/build/Dockerfile . \
|
||||||
|
--build-arg "build_tags=$(BUILD_TAGS)" \
|
||||||
|
--build-arg "build_flags=$(BUILD_FLAGS)" \
|
||||||
|
-t $(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_CUSTOM_TAG) \
|
||||||
|
-t $(DOCKER_IMAGE_NAME):latest
|
||||||
|
|
||||||
bootnode-image:
|
bootnode-image:
|
||||||
@echo "Building docker image for bootnode..."
|
@echo "Building docker image for bootnode..."
|
||||||
docker build --file _assets/build/Dockerfile-bootnode . -t $(BOOTNODE_IMAGE_NAME):latest
|
docker build --file _assets/build/Dockerfile-bootnode . \
|
||||||
|
-t $(BOOTNODE_IMAGE_NAME):$(DOCKER_IMAGE_CUSTOM_TAG) \
|
||||||
|
-t $(BOOTNODE_IMAGE_NAME):latest
|
||||||
|
|
||||||
docker-image-tag: ##@docker Tag DOCKER_IMAGE_NAME:latest with a tag following pattern $GIT_SHA[:8]-$BUILD_TAGS
|
push-docker-images: docker-image bootnode-image
|
||||||
@echo "Tagging docker image..."
|
docker push $(BOOTNODE_IMAGE_NAME):$(DOCKER_IMAGE_CUSTOM_TAG)
|
||||||
docker tag $(DOCKER_IMAGE_NAME):latest $(DOCKER_IMAGE_NAME):$(shell BUILD_TAGS="$(BUILD_TAGS)" ./_assets/ci/get-docker-image-tag.sh)
|
docker push $(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_CUSTOM_TAG)
|
||||||
|
|
||||||
|
push-docker-images-latest: docker-image bootnode-image
|
||||||
|
ifneq ("$(GIT_BRANCH)", "develop")
|
||||||
|
echo "You should only use develop branch to push the latest tag!"
|
||||||
|
exit 1
|
||||||
|
endif
|
||||||
|
ifneq ("$(GIT_LOCAL)", "$(GIT_REMOTE)")
|
||||||
|
echo "The local git commit does not match the remote origin!"
|
||||||
|
exit 1
|
||||||
|
endif
|
||||||
|
docker push $(BOOTNODE_IMAGE_NAME):latest
|
||||||
|
docker push $(DOCKER_IMAGE_NAME):latest
|
||||||
|
|
||||||
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..."
|
||||||
|
|
Loading…
Reference in New Issue