From ef26b1dcc879bb060a23c03bd32faa1df92625e8 Mon Sep 17 00:00:00 2001 From: Roman Gorshunov Date: Wed, 24 Oct 2018 15:48:05 +0200 Subject: [PATCH] Fix: adding back the possibility to add arbitrary labels Arbitrary labels could be added as `make` parameter `LABEL=`, which is used in att-comdev/cicd Jenkins pipelines. Sample parameter: 'LABEL=org.label-schema.vcs-url=${GERRIT_CHANGE_URL} \ --label org.label-schema.base-image=${base_sha256}' Sample usage: See Jenkinsfile files under images/ directory in att-comdev/cicd repo. In addition to that, if `COMMIT` variable is undefined when invoking `make`, we use result of `git rev-parse HEAD` command, which should output latest git commit ID. [0] https://github.com/att-comdev/cicd Change-Id: If4e3425ac92f654f1bff046f20535e619a7e595c --- Makefile | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 93041e87..e47f502d 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,9 @@ PROXY ?= http://proxy.foo.com:8000 NO_PROXY ?= localhost,127.0.0.1,.svc.cluster.local USE_PROXY ?= false PUSH_IMAGE ?= false -COMMIT ?= commit-id +# use this variable for image labels added in internal build process +LABEL ?= com.internal +COMMIT ?= $(shell git rev-parse HEAD) PYTHON = python3 CHARTS := $(patsubst charts/%/.,%,$(wildcard charts/*/.)) IMAGE := ${DOCKER_REGISTRY}/${IMAGE_PREFIX}/${IMAGE_NAME}:${IMAGE_TAG} @@ -118,7 +120,7 @@ $(CHARTS): $(addprefix dry-run-,$(CHARTS)) chartbanner .PHONY: build_promenade build_promenade: ifeq ($(USE_PROXY), true) - docker build --network host -t $(IMAGE) \ + docker build --network host -t $(IMAGE) --label $(LABEL) \ --label "org.opencontainers.image.revision=$(COMMIT)" \ --label "org.opencontainers.image.created=$(shell date --rfc-3339=seconds --utc)" \ --label "org.opencontainers.image.title=$(IMAGE_NAME)" \ @@ -131,7 +133,7 @@ ifeq ($(USE_PROXY), true) --build-arg no_proxy=$(NO_PROXY) \ --build-arg NO_PROXY=$(NO_PROXY) . else - docker build --network host -t $(IMAGE) \ + docker build --network host -t $(IMAGE) --label $(LABEL) \ --label "org.opencontainers.image.revision=$(COMMIT)" \ --label "org.opencontainers.image.created=$(shell date --rfc-3339=seconds --utc)" \ --label "org.opencontainers.image.title=$(IMAGE_NAME)" \