From 1863d36c62d00a0cfddc3859da26a807bd161059 Mon Sep 17 00:00:00 2001 From: Roman Gorshunov Date: Wed, 24 Oct 2018 15:57:39 +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: I7c6b63c865ac0ff63f4a85ec54863c20781fe98d --- Makefile | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 74285819..de2ba7e7 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,9 @@ BUILD_CTX ?= src/bin IMAGE_PREFIX ?= airshipit IMAGE_TAG ?= untagged IMAGE_NAME := airflow shipyard -COMMIT ?= commit-id +# use this variable for image labels added in internal build process +LABEL ?= com.internal +COMMIT ?= $(shell git rev-parse HEAD) DOCKER_REGISTRY ?= quay.io PUSH_IMAGE ?= false @@ -83,7 +85,7 @@ run: .PHONY: build_airflow build_airflow: 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)" \ @@ -97,7 +99,7 @@ ifeq ($(USE_PROXY), true) --build-arg NO_PROXY=$(NO_PROXY) \ --build-arg ctx_base=$(BUILD_CTX) . 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)" \ @@ -112,7 +114,7 @@ endif .PHONY: build_shipyard build_shipyard: 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)" \ @@ -126,7 +128,7 @@ ifeq ($(USE_PROXY), true) --build-arg NO_PROXY=$(NO_PROXY) \ --build-arg ctx_base=$(BUILD_CTX) . 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)" \