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

+ 5
- 3
Makefile View File

@@ -26,7 +26,9 @@ PROXY             ?= http://proxy.foo.com:8000
26 26
 NO_PROXY          ?= localhost,127.0.0.1,.svc.cluster.local
27 27
 USE_PROXY         ?= false
28 28
 PUSH_IMAGE        ?= false
29
-COMMIT            ?= commit-id
29
+# use this variable for image labels added in internal build process
30
+LABEL             ?= com.internal
31
+COMMIT            ?= $(shell git rev-parse HEAD)
30 32
 IMAGE_NAME        := maas-rack-controller maas-region-controller sstream-cache
31 33
 BUILD_DIR         := $(shell mktemp -d)
32 34
 HELM              := $(BUILD_DIR)/helm
@@ -67,7 +69,7 @@ helm-install:
67 69
 .PHONY: build
68 70
 build:
69 71
 ifeq ($(USE_PROXY), true)
70
-	docker build -t $(IMAGE) --network=host \
72
+	docker build -t $(IMAGE) --label $(LABEL) --network=host \
71 73
 		--label "org.opencontainers.image.revision=$(COMMIT)" \
72 74
 		--label "org.opencontainers.image.created=$(shell date --rfc-3339=seconds --utc)" \
73 75
 		--label "org.opencontainers.image.title=$(IMAGE_NAME)" \
@@ -82,7 +84,7 @@ ifeq ($(USE_PROXY), true)
82 84
 		--build-arg SSTREAM_IMAGE=$(SSTREAM_IMAGE) \
83 85
 		$(IMAGE_DIR)
84 86
 else
85
-	docker build -t $(IMAGE) --network=host \
87
+	docker build -t $(IMAGE) --label $(LABEL) --network=host \
86 88
 		--label "org.opencontainers.image.revision=$(COMMIT)" \
87 89
 		--label "org.opencontainers.image.created=$(shell date --rfc-3339=seconds --utc)" \
88 90
 		--label "org.opencontainers.image.title=$(IMAGE_NAME)" \

Loading…
Cancel
Save