From 34f7d760e83709b2ac1555cc0b6aa5e1f3a8561c 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: I78ae651cdcba69e3a9a7a27bafa9a3a13c8eb557 --- Makefile | 2 +- images/drydock/Dockerfile | 7 +++++++ tools/drydock_image_build.sh | 7 +++++-- tools/gate/playbooks/docker-image-build.yaml | 1 + 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 1583645a..f941385d 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 IMAGE ?= ${DOCKER_REGISTRY}/${IMAGE_PREFIX}/${IMAGE_NAME}:${IMAGE_TAG} GO_BUILDER ?= docker.io/golang:1.10-stretch diff --git a/images/drydock/Dockerfile b/images/drydock/Dockerfile index 326c840f..663002de 100644 --- a/images/drydock/Dockerfile +++ b/images/drydock/Dockerfile @@ -13,6 +13,13 @@ # limitations under the License. FROM ubuntu:16.04 +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-drydock.readthedocs.org' +LABEL org.opencontainers.image.source='https://git.openstack.org/openstack/airship-drydock' +LABEL org.opencontainers.image.vendor='The Airship Authors' +LABEL org.opencontainers.image.licenses='Apache-2.0' + ARG UBUNTU_REPO=http://archive.ubuntu.com/ubuntu ARG TRUSTED_UBUNTU_REPO=no ARG ALLOW_UNAUTHENTICATED=false diff --git a/tools/drydock_image_build.sh b/tools/drydock_image_build.sh index cc54b976..41c2a4da 100755 --- a/tools/drydock_image_build.sh +++ b/tools/drydock_image_build.sh @@ -22,7 +22,11 @@ then ADDL_BUILD_ARGS="${ADDL_BUILD_ARGS}| --build-arg PIP_TRUSTED_HOST=${PIP_TRUSTED_HOST}" fi -docker build --network host -t ${IMAGE} --label ${LABEL} -f images/drydock/Dockerfile \ +docker build --network host -t ${IMAGE} \ + --label org.opencontainers.image.revision=${COMMIT} \ + --label org.opencontainers.image.created="$(date --rfc-3339=seconds --utc)" \ + --label org.opencontainers.image.title=${IMAGE_NAME} \ + -f images/drydock/Dockerfile \ ${ADDL_BUILD_ARGS} \ --build-arg BUILD_DIR=${BUILD_DIR} \ --build-arg http_proxy=${http_proxy} \ @@ -31,4 +35,3 @@ docker build --network host -t ${IMAGE} --label ${LABEL} -f images/drydock/Docke --build-arg HTTPS_PROXY=${HTTPS_PROXY} \ --build-arg no_proxy=${no_proxy} \ --build-arg NO_PROXY=${NO_PROXY} . - diff --git a/tools/gate/playbooks/docker-image-build.yaml b/tools/gate/playbooks/docker-image-build.yaml index 63c5185d..aa84bf1b 100644 --- a/tools/gate/playbooks/docker-image-build.yaml +++ b/tools/gate/playbooks/docker-image-build.yaml @@ -83,6 +83,7 @@ DOCKER_REGISTRY: "quay.io" IMAGE_PREFIX: "airshipit" IMAGE_TAG: "{{ item }}" + COMMIT: "{{ zuul.newrev }}" PUSH_IMAGE: "true" with_items: "{{ image_tags.stdout_lines }}"