From c3a364c153a3f37c22ff8e56dbdd56323923f5fd Mon Sep 17 00:00:00 2001 From: Roman Gorshunov Date: Wed, 17 Oct 2018 20:35:40 +0200 Subject: [PATCH] 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 --- Makefile | 16 ++++++++++++---- images/maas-rack-controller/Dockerfile | 8 +++++++- images/maas-region-controller/Dockerfile | 7 +++++++ images/sstream-cache/Dockerfile | 7 +++++++ tools/gate/playbooks/docker-image-build.yaml | 1 + 5 files changed, 34 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 67adac3..949a1ed 100644 --- a/Makefile +++ b/Makefile @@ -26,7 +26,7 @@ PROXY ?= http://proxy.foo.com:8000 NO_PROXY ?= localhost,127.0.0.1,.svc.cluster.local USE_PROXY ?= false PUSH_IMAGE ?= false -LABEL ?= commit-id +COMMIT ?= commit-id IMAGE_NAME := maas-rack-controller maas-region-controller sstream-cache BUILD_DIR := $(shell mktemp -d) HELM := $(BUILD_DIR)/helm @@ -67,7 +67,11 @@ helm-install: .PHONY: build build: ifeq ($(USE_PROXY), true) - docker build -t $(IMAGE) --network=host --label $(LABEL) -f $(IMAGE_DIR)/Dockerfile \ + docker build -t $(IMAGE) --network=host \ + --label "org.opencontainers.image.revision=$(COMMIT)" \ + --label "org.opencontainers.image.created=$(shell date --rfc-3339=seconds --utc)" \ + --label "org.opencontainers.image.title=$(IMAGE_NAME)" \ + -f $(IMAGE_DIR)/Dockerfile \ --build-arg FROM=$(UBUNTU_BASE_IMAGE) \ --build-arg http_proxy=$(PROXY) \ --build-arg https_proxy=$(PROXY) \ @@ -75,10 +79,14 @@ ifeq ($(USE_PROXY), true) --build-arg HTTPS_PROXY=$(PROXY) \ --build-arg no_proxy=$(NO_PROXY) \ --build-arg NO_PROXY=$(NO_PROXY) \ - --build-arg SSTREAM_IMAGE=$(SSTREAM_IMAGE) \ + --build-arg SSTREAM_IMAGE=$(SSTREAM_IMAGE) \ $(IMAGE_DIR) else - docker build -t $(IMAGE) --network=host --label $(LABEL) -f $(IMAGE_DIR)/Dockerfile \ + docker build -t $(IMAGE) --network=host \ + --label "org.opencontainers.image.revision=$(COMMIT)" \ + --label "org.opencontainers.image.created=$(shell date --rfc-3339=seconds --utc)" \ + --label "org.opencontainers.image.title=$(IMAGE_NAME)" \ + -f $(IMAGE_DIR)/Dockerfile \ --build-arg FROM=$(UBUNTU_BASE_IMAGE) \ --build-arg SSTREAM_IMAGE=$(SSTREAM_IMAGE) \ $(IMAGE_DIR) diff --git a/images/maas-rack-controller/Dockerfile b/images/maas-rack-controller/Dockerfile index 0b9b7f4..73510ac 100644 --- a/images/maas-rack-controller/Dockerfile +++ b/images/maas-rack-controller/Dockerfile @@ -1,10 +1,16 @@ ARG FROM=ubuntu:16.04 FROM ${FROM} +LABEL org.opencontainers.image.authors='airship-discuss@lists.airshipit.org, irc://#airshipit@freenode' +LABEL org.opencontainers.image.url='https://airshipit.org' +LABEL org.opencontainers.image.documentation='https://github.com/openstack/airship-maas' +LABEL org.opencontainers.image.source='https://git.openstack.org/openstack/airship-maas' +LABEL org.opencontainers.image.vendor='The Airship Authors' +LABEL org.opencontainers.image.licenses='Apache-2.0' + ENV DEBIAN_FRONTEND noninteractive ENV container docker - # everything else below is to setup maas into the systemd initialized # container based on ubuntu 16.04 RUN apt-get -qq update && \ diff --git a/images/maas-region-controller/Dockerfile b/images/maas-region-controller/Dockerfile index ca9e078..6fb931e 100644 --- a/images/maas-region-controller/Dockerfile +++ b/images/maas-region-controller/Dockerfile @@ -1,6 +1,13 @@ ARG FROM=ubuntu:16.04 FROM ${FROM} +LABEL org.opencontainers.image.authors='airship-discuss@lists.airshipit.org, irc://#airshipit@freenode' +LABEL org.opencontainers.image.url='https://airshipit.org' +LABEL org.opencontainers.image.documentation='https://github.com/openstack/airship-maas' +LABEL org.opencontainers.image.source='https://git.openstack.org/openstack/airship-maas' +LABEL org.opencontainers.image.vendor='The Airship Authors' +LABEL org.opencontainers.image.licenses='Apache-2.0' + ENV DEBIAN_FRONTEND noninteractive ENV container docker diff --git a/images/sstream-cache/Dockerfile b/images/sstream-cache/Dockerfile index c12c244..18d249d 100644 --- a/images/sstream-cache/Dockerfile +++ b/images/sstream-cache/Dockerfile @@ -1,6 +1,13 @@ ARG FROM=ubuntu:16.04 FROM ${FROM} +LABEL org.opencontainers.image.authors='airship-discuss@lists.airshipit.org, irc://#airshipit@freenode' +LABEL org.opencontainers.image.url='https://airshipit.org' +LABEL org.opencontainers.image.documentation='https://github.com/openstack/airship-maas' +LABEL org.opencontainers.image.source='https://git.openstack.org/openstack/airship-maas' +LABEL org.opencontainers.image.vendor='The Airship Authors' +LABEL org.opencontainers.image.licenses='Apache-2.0' + ARG SSTREAM_IMAGE=https://images.maas.io/ephemeral-v3/daily/ ENV IMAGE_SRC ${SSTREAM_IMAGE} diff --git a/tools/gate/playbooks/docker-image-build.yaml b/tools/gate/playbooks/docker-image-build.yaml index 31806f1..116cd4c 100644 --- a/tools/gate/playbooks/docker-image-build.yaml +++ b/tools/gate/playbooks/docker-image-build.yaml @@ -116,6 +116,7 @@ DOCKER_REGISTRY: "quay.io" IMAGE_PREFIX: "airshipit" IMAGE_TAG: "{{ item }}" + COMMIT: "{{ zuul.newrev }}" PUSH_IMAGE: "true" with_items: "{{ image_tags.stdout_lines }}"