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

+ 7
- 5
Makefile View File

@@ -18,7 +18,9 @@ BUILD_CTX                  ?= src/bin
18 18
 IMAGE_PREFIX               ?= airshipit
19 19
 IMAGE_TAG                  ?= untagged
20 20
 IMAGE_NAME                 := airflow shipyard
21
-COMMIT                     ?= commit-id
21
+# use this variable for image labels added in internal build process
22
+LABEL                      ?= com.internal
23
+COMMIT                     ?= $(shell git rev-parse HEAD)
22 24
 
23 25
 DOCKER_REGISTRY            ?= quay.io
24 26
 PUSH_IMAGE                 ?= false
@@ -83,7 +85,7 @@ run:
83 85
 .PHONY: build_airflow
84 86
 build_airflow:
85 87
 ifeq ($(USE_PROXY), true)
86
-	docker build --network host -t $(IMAGE) \
88
+	docker build --network host -t $(IMAGE) --label $(LABEL) \
87 89
 		--label "org.opencontainers.image.revision=$(COMMIT)" \
88 90
 		--label "org.opencontainers.image.created=$(shell date --rfc-3339=seconds --utc)" \
89 91
 		--label "org.opencontainers.image.title=$(IMAGE_NAME)" \
@@ -97,7 +99,7 @@ ifeq ($(USE_PROXY), true)
97 99
 		--build-arg NO_PROXY=$(NO_PROXY) \
98 100
 		--build-arg ctx_base=$(BUILD_CTX) .
99 101
 else
100
-	docker build --network host -t $(IMAGE) \
102
+	docker build --network host -t $(IMAGE) --label $(LABEL) \
101 103
 		--label "org.opencontainers.image.revision=$(COMMIT)" \
102 104
 		--label "org.opencontainers.image.created=$(shell date --rfc-3339=seconds --utc)" \
103 105
 		--label "org.opencontainers.image.title=$(IMAGE_NAME)" \
@@ -112,7 +114,7 @@ endif
112 114
 .PHONY: build_shipyard
113 115
 build_shipyard:
114 116
 ifeq ($(USE_PROXY), true)
115
-	docker build --network host -t $(IMAGE) \
117
+	docker build --network host -t $(IMAGE) --label $(LABEL) \
116 118
 		--label "org.opencontainers.image.revision=$(COMMIT)" \
117 119
 		--label "org.opencontainers.image.created=$(shell date --rfc-3339=seconds --utc)" \
118 120
 		--label "org.opencontainers.image.title=$(IMAGE_NAME)" \
@@ -126,7 +128,7 @@ ifeq ($(USE_PROXY), true)
126 128
 		--build-arg NO_PROXY=$(NO_PROXY) \
127 129
 		--build-arg ctx_base=$(BUILD_CTX) .
128 130
 else
129
-	docker build --network host -t $(IMAGE) \
131
+	docker build --network host -t $(IMAGE) --label $(LABEL) \
130 132
 		--label "org.opencontainers.image.revision=$(COMMIT)" \
131 133
 		--label "org.opencontainers.image.created=$(shell date --rfc-3339=seconds --utc)" \
132 134
 		--label "org.opencontainers.image.title=$(IMAGE_NAME)" \

Loading…
Cancel
Save