From 655b1ae3c3507df7fc37e1d50e03db5d3ec37429 Mon Sep 17 00:00:00 2001 From: Roman Gorshunov Date: Fri, 21 Sep 2018 03:31:13 +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: Iedd64fa70016880d5df241d27d8dad101e10130b --- Makefile | 26 +++++++++++++++---- images/airflow/Dockerfile | 7 +++++ images/shipyard/Dockerfile | 7 +++++ .../build-images/tasks/airship-shipyard.yaml | 1 + 4 files changed, 36 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 57335940..8618aca2 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ BUILD_CTX ?= src/bin IMAGE_PREFIX ?= airshipit IMAGE_TAG ?= untagged IMAGE_NAME := airflow shipyard -LABEL ?= commit-id +COMMIT ?= commit-id DOCKER_REGISTRY ?= quay.io PUSH_IMAGE ?= false @@ -86,7 +86,11 @@ run: .PHONY: build_airflow build_airflow: ifeq ($(USE_PROXY), true) - docker build --network host -t $(IMAGE) --label $(LABEL) -f $(IMAGE_DIR)/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 $(IMAGE_DIR)/Dockerfile \ --build-arg FROM=$(UBUNTU_BASE_IMAGE) \ --build-arg http_proxy=$(PROXY) \ --build-arg https_proxy=$(PROXY) \ @@ -96,7 +100,11 @@ ifeq ($(USE_PROXY), true) --build-arg NO_PROXY=$(NO_PROXY) \ --build-arg ctx_base=$(BUILD_CTX) . else - docker build --network host -t $(IMAGE) --label $(LABEL) -f $(IMAGE_DIR)/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 $(IMAGE_DIR)/Dockerfile \ --build-arg FROM=$(UBUNTU_BASE_IMAGE) \ --build-arg ctx_base=$(BUILD_CTX) . endif @@ -107,7 +115,11 @@ endif .PHONY: build_shipyard build_shipyard: ifeq ($(USE_PROXY), true) - docker build --network host -t $(IMAGE) --label $(LABEL) -f $(IMAGE_DIR)/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 $(IMAGE_DIR)/Dockerfile \ --build-arg FROM=$(PYTHON_BASE_IMAGE) \ --build-arg http_proxy=$(PROXY) \ --build-arg https_proxy=$(PROXY) \ @@ -117,7 +129,11 @@ ifeq ($(USE_PROXY), true) --build-arg NO_PROXY=$(NO_PROXY) \ --build-arg ctx_base=$(BUILD_CTX) . else - docker build --network host -t $(IMAGE) --label $(LABEL) -f $(IMAGE_DIR)/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 $(IMAGE_DIR)/Dockerfile \ --build-arg FROM=$(PYTHON_BASE_IMAGE) \ --build-arg ctx_base=$(BUILD_CTX) . endif diff --git a/images/airflow/Dockerfile b/images/airflow/Dockerfile index 7f1cf1ad..2181206e 100644 --- a/images/airflow/Dockerfile +++ b/images/airflow/Dockerfile @@ -16,6 +16,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://airship-shipyard.readthedocs.org' +LABEL org.opencontainers.image.source='https://git.openstack.org/openstack/airship-shipyard' +LABEL org.opencontainers.image.vendor='The Airship Authors' +LABEL org.opencontainers.image.licenses='Apache-2.0' + # Do not prompt user for choices on installation/configuration of packages # Set port 8080 for Airflow Web # Set port 5555 for Airflow Flower diff --git a/images/shipyard/Dockerfile b/images/shipyard/Dockerfile index 1fdb1f4a..ae37ef71 100644 --- a/images/shipyard/Dockerfile +++ b/images/shipyard/Dockerfile @@ -15,6 +15,13 @@ ARG FROM=python:3.5 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://airship-shipyard.readthedocs.org' +LABEL org.opencontainers.image.source='https://git.openstack.org/openstack/airship-shipyard' +LABEL org.opencontainers.image.vendor='The Airship Authors' +LABEL org.opencontainers.image.licenses='Apache-2.0' + ENV container docker ENV PORT 9000 ENV LC_ALL C.UTF-8 diff --git a/tools/gate/roles/build-images/tasks/airship-shipyard.yaml b/tools/gate/roles/build-images/tasks/airship-shipyard.yaml index 637cbd51..c83496dd 100644 --- a/tools/gate/roles/build-images/tasks/airship-shipyard.yaml +++ b/tools/gate/roles/build-images/tasks/airship-shipyard.yaml @@ -109,6 +109,7 @@ DOCKER_REGISTRY: "quay.io" IMAGE_PREFIX: "airshipit" IMAGE_TAG: "{{ item }}" + COMMIT: "{{ zuul.newrev }}" PUSH_IMAGE: "true" with_items: "{{ image_tags.stdout_lines }}"