Browse Source

Fix: git commit id labels on images

1) Use OCI Image Specs for labels instead of custom 'commit-id=xxxxx'
   or legacy "Label Schema"
2) Fix missing git commit id labels on images (.revision)
3) Add human-readable title (.title) of the image, URL (.url), and
   a few other properties (annotations) according to the latest Specs

Change-Id: I8ee3aef8d64efe6237f630caab3683f7137d4e68
Roman Gorshunov 6 months ago
parent
commit
c3a364c153

+ 12
- 4
Makefile View File

@@ -26,7 +26,7 @@ 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
-LABEL             ?= commit-id
29
+COMMIT            ?= commit-id
30 30
 IMAGE_NAME        := maas-rack-controller maas-region-controller sstream-cache
31 31
 BUILD_DIR         := $(shell mktemp -d)
32 32
 HELM              := $(BUILD_DIR)/helm
@@ -67,7 +67,11 @@ helm-install:
67 67
 .PHONY: build
68 68
 build:
69 69
 ifeq ($(USE_PROXY), true)
70
-	docker build -t $(IMAGE) --network=host --label $(LABEL) -f $(IMAGE_DIR)/Dockerfile \
70
+	docker build -t $(IMAGE) --network=host \
71
+		--label "org.opencontainers.image.revision=$(COMMIT)" \
72
+		--label "org.opencontainers.image.created=$(shell date --rfc-3339=seconds --utc)" \
73
+		--label "org.opencontainers.image.title=$(IMAGE_NAME)" \
74
+		-f $(IMAGE_DIR)/Dockerfile \
71 75
 		--build-arg FROM=$(UBUNTU_BASE_IMAGE) \
72 76
 		--build-arg http_proxy=$(PROXY) \
73 77
 		--build-arg https_proxy=$(PROXY) \
@@ -75,10 +79,14 @@ ifeq ($(USE_PROXY), true)
75 79
 		--build-arg HTTPS_PROXY=$(PROXY) \
76 80
 		--build-arg no_proxy=$(NO_PROXY) \
77 81
 		--build-arg NO_PROXY=$(NO_PROXY) \
78
-                --build-arg SSTREAM_IMAGE=$(SSTREAM_IMAGE) \
82
+		--build-arg SSTREAM_IMAGE=$(SSTREAM_IMAGE) \
79 83
 		$(IMAGE_DIR)
80 84
 else
81
-	docker build -t $(IMAGE) --network=host --label $(LABEL) -f $(IMAGE_DIR)/Dockerfile \
85
+	docker build -t $(IMAGE) --network=host \
86
+		--label "org.opencontainers.image.revision=$(COMMIT)" \
87
+		--label "org.opencontainers.image.created=$(shell date --rfc-3339=seconds --utc)" \
88
+		--label "org.opencontainers.image.title=$(IMAGE_NAME)" \
89
+		-f $(IMAGE_DIR)/Dockerfile \
82 90
 		--build-arg FROM=$(UBUNTU_BASE_IMAGE) \
83 91
 		--build-arg SSTREAM_IMAGE=$(SSTREAM_IMAGE) \
84 92
 		$(IMAGE_DIR)

+ 7
- 1
images/maas-rack-controller/Dockerfile View File

@@ -1,10 +1,16 @@
1 1
 ARG FROM=ubuntu:16.04
2 2
 FROM ${FROM}
3 3
 
4
+LABEL org.opencontainers.image.authors='airship-discuss@lists.airshipit.org, irc://#airshipit@freenode'
5
+LABEL org.opencontainers.image.url='https://airshipit.org'
6
+LABEL org.opencontainers.image.documentation='https://github.com/openstack/airship-maas'
7
+LABEL org.opencontainers.image.source='https://git.openstack.org/openstack/airship-maas'
8
+LABEL org.opencontainers.image.vendor='The Airship Authors'
9
+LABEL org.opencontainers.image.licenses='Apache-2.0'
10
+
4 11
 ENV DEBIAN_FRONTEND noninteractive
5 12
 ENV container docker
6 13
 
7
-
8 14
 # everything else below is to setup maas into the systemd initialized
9 15
 # container based on ubuntu 16.04
10 16
 RUN apt-get -qq update && \

+ 7
- 0
images/maas-region-controller/Dockerfile View File

@@ -1,6 +1,13 @@
1 1
 ARG FROM=ubuntu:16.04
2 2
 FROM ${FROM}
3 3
 
4
+LABEL org.opencontainers.image.authors='airship-discuss@lists.airshipit.org, irc://#airshipit@freenode'
5
+LABEL org.opencontainers.image.url='https://airshipit.org'
6
+LABEL org.opencontainers.image.documentation='https://github.com/openstack/airship-maas'
7
+LABEL org.opencontainers.image.source='https://git.openstack.org/openstack/airship-maas'
8
+LABEL org.opencontainers.image.vendor='The Airship Authors'
9
+LABEL org.opencontainers.image.licenses='Apache-2.0'
10
+
4 11
 ENV DEBIAN_FRONTEND noninteractive
5 12
 ENV container docker
6 13
 

+ 7
- 0
images/sstream-cache/Dockerfile View File

@@ -1,6 +1,13 @@
1 1
 ARG FROM=ubuntu:16.04
2 2
 FROM ${FROM}
3 3
 
4
+LABEL org.opencontainers.image.authors='airship-discuss@lists.airshipit.org, irc://#airshipit@freenode'
5
+LABEL org.opencontainers.image.url='https://airshipit.org'
6
+LABEL org.opencontainers.image.documentation='https://github.com/openstack/airship-maas'
7
+LABEL org.opencontainers.image.source='https://git.openstack.org/openstack/airship-maas'
8
+LABEL org.opencontainers.image.vendor='The Airship Authors'
9
+LABEL org.opencontainers.image.licenses='Apache-2.0'
10
+
4 11
 ARG SSTREAM_IMAGE=https://images.maas.io/ephemeral-v3/daily/
5 12
 ENV IMAGE_SRC ${SSTREAM_IMAGE}
6 13
 

+ 1
- 0
tools/gate/playbooks/docker-image-build.yaml View File

@@ -116,6 +116,7 @@
116 116
               DOCKER_REGISTRY: "quay.io"
117 117
               IMAGE_PREFIX: "airshipit"
118 118
               IMAGE_TAG: "{{ item }}"
119
+              COMMIT: "{{ zuul.newrev }}"
119 120
               PUSH_IMAGE: "true"
120 121
           with_items: "{{ image_tags.stdout_lines }}"
121 122
 

Loading…
Cancel
Save