From 2c09054c4be0b41f9babb7c95d352d03b05c6bc9 Mon Sep 17 00:00:00 2001 From: Roman Gorshunov Date: Wed, 24 Oct 2018 15:42:58 +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: I9193ca03cb3970e3a3e1cb64ff643a4d24543636 --- Makefile | 4 +++- tools/drydock_image_build.sh | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 3aa94532..9429ab48 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 ?= org.airshipit.build=community +COMMIT ?= $(shell git rev-parse HEAD) IMAGE ?= ${DOCKER_REGISTRY}/${IMAGE_PREFIX}/${IMAGE_NAME}:${IMAGE_TAG} GO_BUILDER ?= docker.io/golang:1.10-stretch diff --git a/tools/drydock_image_build.sh b/tools/drydock_image_build.sh index 41c2a4da..e0e585ad 100755 --- a/tools/drydock_image_build.sh +++ b/tools/drydock_image_build.sh @@ -22,7 +22,7 @@ then ADDL_BUILD_ARGS="${ADDL_BUILD_ARGS}| --build-arg PIP_TRUSTED_HOST=${PIP_TRUSTED_HOST}" fi -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="$(date --rfc-3339=seconds --utc)" \ --label org.opencontainers.image.title=${IMAGE_NAME} \