Merge "Fix: git commit id labels on images"

This commit is contained in:
Zuul 2018-09-25 16:45:38 +00:00 committed by Gerrit Code Review
commit 7c1d81f86c
3 changed files with 18 additions and 4 deletions

View File

@ -1,7 +1,12 @@
ARG FROM=python:3.5 ARG FROM=python:3.5
FROM ${FROM} 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 DEBIAN_FRONTEND noninteractive
ENV LANG=C.UTF-8 ENV LANG=C.UTF-8

View File

@ -22,7 +22,7 @@ PROXY ?= http://proxy.foo.com:8000
NO_PROXY ?= localhost,127.0.0.1,.svc.cluster.local NO_PROXY ?= localhost,127.0.0.1,.svc.cluster.local
USE_PROXY ?= false USE_PROXY ?= false
PUSH_IMAGE ?= false PUSH_IMAGE ?= false
LABEL ?= commit-id COMMIT ?= commit-id
PYTHON = python3 PYTHON = python3
CHARTS := $(patsubst charts/%/.,%,$(wildcard charts/*/.)) CHARTS := $(patsubst charts/%/.,%,$(wildcard charts/*/.))
IMAGE := ${DOCKER_REGISTRY}/${IMAGE_PREFIX}/${IMAGE_NAME}:${IMAGE_TAG} IMAGE := ${DOCKER_REGISTRY}/${IMAGE_PREFIX}/${IMAGE_NAME}:${IMAGE_TAG}
@ -103,7 +103,11 @@ run_armada: build_armada
.PHONY: build_armada .PHONY: build_armada
build_armada: build_armada:
ifeq ($(USE_PROXY), true) 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 FROM=$(PYTHON_BASE_IMAGE) \
--build-arg http_proxy=$(PROXY) \ --build-arg http_proxy=$(PROXY) \
--build-arg https_proxy=$(PROXY) \ --build-arg https_proxy=$(PROXY) \
@ -112,7 +116,11 @@ ifeq ($(USE_PROXY), true)
--build-arg no_proxy=$(NO_PROXY) \ --build-arg no_proxy=$(NO_PROXY) \
--build-arg NO_PROXY=$(NO_PROXY) . --build-arg NO_PROXY=$(NO_PROXY) .
else 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) . --build-arg FROM=$(PYTHON_BASE_IMAGE) .
endif endif
ifeq ($(PUSH_IMAGE), true) ifeq ($(PUSH_IMAGE), true)

View File

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