Browse Source

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
Roman Gorshunov 5 months ago
parent
commit
ef26b1dcc8
1 changed files with 5 additions and 3 deletions
  1. 5
    3
      Makefile

+ 5
- 3
Makefile View File

@@ -22,7 +22,9 @@ PROXY             ?= http://proxy.foo.com:8000
22 22
 NO_PROXY          ?= localhost,127.0.0.1,.svc.cluster.local
23 23
 USE_PROXY         ?= false
24 24
 PUSH_IMAGE        ?= false
25
-COMMIT            ?= commit-id
25
+# use this variable for image labels added in internal build process
26
+LABEL             ?= com.internal
27
+COMMIT            ?= $(shell git rev-parse HEAD)
26 28
 PYTHON            = python3
27 29
 CHARTS            := $(patsubst charts/%/.,%,$(wildcard charts/*/.))
28 30
 IMAGE             := ${DOCKER_REGISTRY}/${IMAGE_PREFIX}/${IMAGE_NAME}:${IMAGE_TAG}
@@ -118,7 +120,7 @@ $(CHARTS): $(addprefix dry-run-,$(CHARTS)) chartbanner
118 120
 .PHONY: build_promenade
119 121
 build_promenade:
120 122
 ifeq ($(USE_PROXY), true)
121
-	docker build --network host -t $(IMAGE) \
123
+	docker build --network host -t $(IMAGE) --label $(LABEL) \
122 124
 		--label "org.opencontainers.image.revision=$(COMMIT)" \
123 125
 		--label "org.opencontainers.image.created=$(shell date --rfc-3339=seconds --utc)" \
124 126
 		--label "org.opencontainers.image.title=$(IMAGE_NAME)" \
@@ -131,7 +133,7 @@ ifeq ($(USE_PROXY), true)
131 133
 		--build-arg no_proxy=$(NO_PROXY) \
132 134
 		--build-arg NO_PROXY=$(NO_PROXY) .
133 135
 else
134
-	docker build --network host -t $(IMAGE) \
136
+	docker build --network host -t $(IMAGE) --label $(LABEL) \
135 137
 		--label "org.opencontainers.image.revision=$(COMMIT)" \
136 138
 		--label "org.opencontainers.image.created=$(shell date --rfc-3339=seconds --utc)" \
137 139
 		--label "org.opencontainers.image.title=$(IMAGE_NAME)" \

Loading…
Cancel
Save