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: I795d1443f60f362c5ecb244cb90ee8052603854f
This commit is contained in:
parent
b4cd48cde0
commit
e2edd5fef9
8
Makefile
8
Makefile
@ -21,7 +21,9 @@ PROXY ?= http://proxy.foo.com:8000
|
|||||||
NO_PROXY ?= localhost,127.0.0.1,.svc.cluster.local
|
NO_PROXY ?= localhost,127.0.0.1,.svc.cluster.local
|
||||||
USE_PROXY ?= false
|
USE_PROXY ?= false
|
||||||
PUSH_IMAGE ?= 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)
|
||||||
IMAGE := ${DOCKER_REGISTRY}/${IMAGE_PREFIX}/${IMAGE_NAME}:${IMAGE_TAG}
|
IMAGE := ${DOCKER_REGISTRY}/${IMAGE_PREFIX}/${IMAGE_NAME}:${IMAGE_TAG}
|
||||||
|
|
||||||
# Build Deckhand Docker image for this project
|
# Build Deckhand Docker image for this project
|
||||||
@ -52,7 +54,7 @@ tests:
|
|||||||
.PHONY: build_deckhand
|
.PHONY: build_deckhand
|
||||||
build_deckhand:
|
build_deckhand:
|
||||||
ifeq ($(USE_PROXY), true)
|
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.revision=$(COMMIT)" \
|
||||||
--label "org.opencontainers.image.created=$(shell date --rfc-3339=seconds --utc)" \
|
--label "org.opencontainers.image.created=$(shell date --rfc-3339=seconds --utc)" \
|
||||||
--label "org.opencontainers.image.title=$(IMAGE_NAME)" \
|
--label "org.opencontainers.image.title=$(IMAGE_NAME)" \
|
||||||
@ -64,7 +66,7 @@ ifeq ($(USE_PROXY), true)
|
|||||||
--build-arg no_proxy=$(NO_PROXY) \
|
--build-arg no_proxy=$(NO_PROXY) \
|
||||||
--build-arg NO_PROXY=$(NO_PROXY) .
|
--build-arg NO_PROXY=$(NO_PROXY) .
|
||||||
else
|
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.revision=$(COMMIT)" \
|
||||||
--label "org.opencontainers.image.created=$(shell date --rfc-3339=seconds --utc)" \
|
--label "org.opencontainers.image.created=$(shell date --rfc-3339=seconds --utc)" \
|
||||||
--label "org.opencontainers.image.title=$(IMAGE_NAME)" \
|
--label "org.opencontainers.image.title=$(IMAGE_NAME)" \
|
||||||
|
Loading…
Reference in New Issue
Block a user