Skip to content

Commit

Permalink
Support tagged releases
Browse files Browse the repository at this point in the history
**What**
- Add TAG variable to the build process so that tagged releases are easy
  to create

Signed-off-by: Lucas Roesler <[email protected]>
  • Loading branch information
LucasRoesler committed Jun 19, 2020
1 parent 7235cab commit 1939dfa
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.NAME := openfaas-loki
.PKG := github.com/LucasRoesler/$(.NAME)
.IMAGE_PREFIX=theaxer/$(.NAME)
.TAG=latest

.GIT_COMMIT=$(shell git rev-parse HEAD)
.GIT_VERSION=$(shell git describe --tags 2>/dev/null || echo "$(.GIT_COMMIT)")
Expand Down Expand Up @@ -63,34 +64,34 @@ build: $(addprefix build-,$(ARCHS)) ## Build Docker images for all architecture
.PHONY: build-%
build-%:
DOCKER_BUILDKIT=1 docker build $(BUILD_ARGS) --build-arg go_opts="GOARCH=$*" \
-t ${.IMAGE_PREFIX}:latest-$* \
-t ${.IMAGE_PREFIX}:${.TAG}-$* \
-f ./Dockerfile .

build-armhf:
DOCKER_BUILDKIT=1 docker build $(BUILD_ARGS) --build-arg go_opts="GOARCH=arm GOARM=6" \
-t ${.IMAGE_PREFIX}:latest-armhf \
-t ${.IMAGE_PREFIX}:${.TAG}-armhf \
-f ./Dockerfile .

.PHONY: push
push: $(addprefix push-,$(ARCHS)) ## Push Docker images for all architectures

.PHONY: push-%
push-%:
docker push ${.IMAGE_PREFIX}:latest-$*
docker push ${.IMAGE_PREFIX}:${.TAG}-$*

.PHONY: manifest
manifest: ## Create and push Docker manifest to combine all architectures in multi-arch Docker image
docker manifest create --amend ${.IMAGE_PREFIX}:latest $(addprefix ${.IMAGE_PREFIX}:latest-,$(ARCHS))
docker manifest create --amend ${.IMAGE_PREFIX}:${.TAG} $(addprefix ${.IMAGE_PREFIX}:${.TAG}-,$(ARCHS))
$(MAKE) $(addprefix manifest-annotate-,$(ARCHS))
docker manifest push -p ${.IMAGE_PREFIX}:latest
docker manifest push -p ${.IMAGE_PREFIX}:${.TAG}

.PHONY: manifest-annotate-%
manifest-annotate-%:
docker manifest annotate ${.IMAGE_PREFIX}:latest ${.IMAGE_PREFIX}:latest-$* --os linux --arch $*
docker manifest annotate ${.IMAGE_PREFIX}:${.TAG} ${.IMAGE_PREFIX}:${.TAG}-$* --os linux --arch $*

.PHONY: manifest-annotate-armhf
manifest-annotate-armhf:
docker manifest annotate ${.IMAGE_PREFIX}:latest ${.IMAGE_PREFIX}:latest-armhf --os linux --arch arm --variant v6
docker manifest annotate ${.IMAGE_PREFIX}:${.TAG} ${.IMAGE_PREFIX}:${.TAG}-armhf --os linux --arch arm --variant v6

.PHONY: package
package: ## Package the helm chart
Expand Down

0 comments on commit 1939dfa

Please sign in to comment.