From 4d066c5097d6de9f88f4a8d2c05d5958d2ecc609 Mon Sep 17 00:00:00 2001 From: Sal Tijerina Date: Thu, 8 Feb 2024 16:49:38 -0600 Subject: [PATCH 1/3] update Makefile to support git branches --- Makefile | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Makefile b/Makefile index a7300d96a..c34437fa1 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,10 @@ PROJECT_NAME := $(shell cat ./project_name.var) NEEDS_DEMO := $(shell cat ./needs_demo.var) BUILD_ID := $(shell git describe --always) +# NOTE: The `DOCKER_IMAGE_BRANCH` tag is the git tag for the commit if it exists, else the branch on which the commit exists. +# NOTE: Special characters in `DOCKER_IMAGE_BRANCH` are replaced with spaces. +DOCKER_IMAGE_BRANCH := $(DOCKERHUB_REPO):$(shell git describe --exact-match --tags 2> /dev/null || git symbolic-ref --short HEAD | sed 's/[^[:alnum:]\.\_\-]/-/g') + .PHONY: build build: docker-compose -f ./docker-compose.yml build @@ -20,6 +24,8 @@ build-full: --build-arg NEEDS_DEMO="$(NEEDS_DEMO)" \ -f ./Dockerfile . + docker tag $(DOCKER_IMAGE) $(DOCKER_IMAGE_BRANCH) + .PHONY: example example: docker-compose -f ./docker-compose.example.yml up @@ -27,6 +33,7 @@ example: .PHONY: publish publish: docker push $(DOCKER_IMAGE) + docker push $(DOCKER_IMAGE_BRANCH) .PHONY: publish-latest publish-latest: From 187b528739d07aaae068f8a8b79a2951a45a5659 Mon Sep 17 00:00:00 2001 From: Sal Tijerina Date: Thu, 8 Feb 2024 16:52:02 -0600 Subject: [PATCH 2/3] fix comment --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index c34437fa1..8b212f589 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ NEEDS_DEMO := $(shell cat ./needs_demo.var) BUILD_ID := $(shell git describe --always) # NOTE: The `DOCKER_IMAGE_BRANCH` tag is the git tag for the commit if it exists, else the branch on which the commit exists. -# NOTE: Special characters in `DOCKER_IMAGE_BRANCH` are replaced with spaces. +# NOTE: Special characters in `DOCKER_IMAGE_BRANCH` are replaced with dashes. DOCKER_IMAGE_BRANCH := $(DOCKERHUB_REPO):$(shell git describe --exact-match --tags 2> /dev/null || git symbolic-ref --short HEAD | sed 's/[^[:alnum:]\.\_\-]/-/g') .PHONY: build From 783b7fbdd8ceb94f00f55280314799d917b4582a Mon Sep 17 00:00:00 2001 From: Sal Tijerina Date: Fri, 9 Feb 2024 10:34:45 -0600 Subject: [PATCH 3/3] rearrange vars --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 8b212f589..20f558083 100644 --- a/Makefile +++ b/Makefile @@ -3,14 +3,14 @@ DOCKER_TAG ?= $(shell git rev-parse --short HEAD) DOCKER_IMAGE := $(DOCKERHUB_REPO):$(DOCKER_TAG) DOCKER_IMAGE_LATEST := $(DOCKERHUB_REPO):latest -PROJECT_NAME := $(shell cat ./project_name.var) -NEEDS_DEMO := $(shell cat ./needs_demo.var) -BUILD_ID := $(shell git describe --always) - # NOTE: The `DOCKER_IMAGE_BRANCH` tag is the git tag for the commit if it exists, else the branch on which the commit exists. # NOTE: Special characters in `DOCKER_IMAGE_BRANCH` are replaced with dashes. DOCKER_IMAGE_BRANCH := $(DOCKERHUB_REPO):$(shell git describe --exact-match --tags 2> /dev/null || git symbolic-ref --short HEAD | sed 's/[^[:alnum:]\.\_\-]/-/g') +PROJECT_NAME := $(shell cat ./project_name.var) +NEEDS_DEMO := $(shell cat ./needs_demo.var) +BUILD_ID := $(shell git describe --always) + .PHONY: build build: docker-compose -f ./docker-compose.yml build