From b6358d24b996967475dd1398bcf2a7f7e8ab8eb4 Mon Sep 17 00:00:00 2001 From: Roman Gorshunov Date: Fri, 21 Sep 2018 03:31:12 +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: I7029d7caf521c7f56c1046fff9ecdd4e81090618 --- Dockerfile | 7 ++++++- Makefile | 14 +++++++++++--- tools/gate/playbooks/docker-image-build.yaml | 1 + 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index a9c55e8f..4a27824e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,12 @@ ARG FROM=python:3.5 FROM ${FROM} -MAINTAINER Armada Team +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://airship-armada.readthedocs.org' +LABEL org.opencontainers.image.source='https://git.openstack.org/openstack/airship-armada' +LABEL org.opencontainers.image.vendor='The Airship Authors' +LABEL org.opencontainers.image.licenses='Apache-2.0' ENV DEBIAN_FRONTEND noninteractive ENV LANG=C.UTF-8 diff --git a/Makefile b/Makefile index 85401891..e8791ab6 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,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 PYTHON = python3 CHARTS := $(patsubst charts/%/.,%,$(wildcard charts/*/.)) IMAGE := ${DOCKER_REGISTRY}/${IMAGE_PREFIX}/${IMAGE_NAME}:${IMAGE_TAG} @@ -104,7 +104,11 @@ build_docs: .PHONY: build_armada build_armada: ifeq ($(USE_PROXY), true) - docker build --network host -t $(IMAGE) --label $(LABEL) -f ./Dockerfile \ + docker build --network host -t $(IMAGE) \ + --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 ./Dockerfile \ --build-arg FROM=$(PYTHON_BASE_IMAGE) \ --build-arg http_proxy=$(PROXY) \ --build-arg https_proxy=$(PROXY) \ @@ -113,7 +117,11 @@ ifeq ($(USE_PROXY), true) --build-arg no_proxy=$(NO_PROXY) \ --build-arg NO_PROXY=$(NO_PROXY) . else - docker build --network host -t $(IMAGE) --label $(LABEL) -f ./Dockerfile \ + docker build --network host -t $(IMAGE) \ + --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 ./Dockerfile \ --build-arg FROM=$(PYTHON_BASE_IMAGE) . endif ifeq ($(PUSH_IMAGE), true) diff --git a/tools/gate/playbooks/docker-image-build.yaml b/tools/gate/playbooks/docker-image-build.yaml index 8444fa87..8a1b7898 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 }}"