From 6cfe98e0c3301421656b6181880510f9ed359903 Mon Sep 17 00:00:00 2001 From: "Hughes, Alexander (ah8742)" Date: Fri, 7 Jun 2019 14:01:35 +0000 Subject: [PATCH] Multi multi distro support images This patch: 1. Resolves an issue where the base image was overrided with python:3.6 2. Adds framework for creating new images of other distributions and gating against them. Change-Id: Iaa8ec86f947189bf24d40e5594e015554f7abddb --- .zuul.yaml | 14 ++++--- Makefile | 40 +++++++++++-------- .../{Dockerfile => Dockerfile.ubuntu_xenial} | 0 tools/gate/playbooks/docker-image-build.yaml | 4 ++ tools/spyglass.sh | 2 +- 5 files changed, 36 insertions(+), 24 deletions(-) rename images/spyglass/{Dockerfile => Dockerfile.ubuntu_xenial} (100%) diff --git a/.zuul.yaml b/.zuul.yaml index 183ca97..235d518 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -18,15 +18,15 @@ check: jobs: - openstack-tox-pep8 - - spyglass-docker-build-gate + - spyglass-docker-build-gate-ubuntu_xenial gate: jobs: - openstack-tox-pep8 - - spyglass-docker-build-gate + - spyglass-docker-build-gate-ubuntu_xenial post: jobs: - - spyglass-docker-publish - spyglass-upload-git-mirror + - spyglass-docker-publish-ubuntu_xenial - nodeset: name: spyglass-single-node @@ -35,25 +35,27 @@ label: ubuntu-xenial - job: - name: spyglass-docker-build-gate + name: spyglass-docker-build-gate-ubuntu_xenial timeout: 1800 run: tools/gate/playbooks/docker-image-build.yaml nodeset: spyglass-single-node vars: publish: false + distro: ubuntu_xenial tags: dynamic: patch_set: true - job: - name: spyglass-docker-publish + name: spyglass-docker-publish-ubuntu_xenial timeout: 1800 run: tools/gate/playbooks/docker-image-build.yaml - nodeset: armada-single-node + nodeset: spyglass-single-node secrets: - airship_spyglass_quay_creds vars: publish: true + distro: ubuntu_xenial tags: dynamic: branch: true diff --git a/Makefile b/Makefile index 1695188..c8fc65a 100644 --- a/Makefile +++ b/Makefile @@ -12,20 +12,24 @@ # See the License for the specific language governing permissions and # limitations under the License. -SPYGLASS_BUILD_CTX ?= . -IMAGE_NAME ?= spyglass -IMAGE_PREFIX ?= airshipit -DOCKER_REGISTRY ?= quay.io -IMAGE_TAG ?= latest -PROXY ?= http://proxy.foo.com:8000 -NO_PROXY ?= localhost,127.0.0.1,.svc.cluster.local -USE_PROXY ?= false -PUSH_IMAGE ?= false +SPYGLASS_BUILD_CTX ?= spyglass +IMAGE_NAME ?= spyglass +IMAGE_PREFIX ?= airshipit +DOCKER_REGISTRY ?= quay.io +IMAGE_TAG ?= latest +HELM ?= helm +PROXY ?= http://proxy.foo.com:8000 +NO_PROXY ?= localhost,127.0.0.1,.svc.cluster.local +USE_PROXY ?= false +PUSH_IMAGE ?= false # use this variable for image labels added in internal build process -LABEL ?= org.airshipit.build=community -COMMIT ?= $(shell git rev-parse HEAD) -IMAGE ?= $(DOCKER_REGISTRY)/$(IMAGE_PREFIX)/$(IMAGE_NAME):$(IMAGE_TAG) -PYTHON_BASE_IMAGE ?= python:3.6 +LABEL ?= org.airshipit.build=community +COMMIT ?= $(shell git rev-parse HEAD) +DISTRO ?= ubuntu_xenial +IMAGE ?= $(DOCKER_REGISTRY)/$(IMAGE_PREFIX)/$(IMAGE_NAME):$(IMAGE_TAG)-${DISTRO} +PYTHON_BASE_IMAGE ?= python:3.6 +BASE_IMAGE ?= + export # Build all docker images for this project @@ -55,6 +59,8 @@ lint: py_lint .PHONY: format format: py_format +_BASE_IMAGE_ARG := $(if $(BASE_IMAGE),--build-arg FROM="${BASE_IMAGE}" ,) + .PHONY: build_spyglass build_spyglass: ifeq ($(USE_PROXY), true) @@ -62,8 +68,8 @@ ifeq ($(USE_PROXY), true) --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 images/spyglass/Dockerfile \ - --build-arg FROM=$(PYTHON_BASE_IMAGE) \ + -f images/spyglass/Dockerfile.$(DISTRO) \ + $(_BASE_IMAGE_ARG) \ --build-arg http_proxy=$(PROXY) \ --build-arg https_proxy=$(PROXY) \ --build-arg HTTP_PROXY=$(PROXY) \ @@ -76,8 +82,8 @@ else --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 images/spyglass/Dockerfile \ - --build-arg FROM=$(PYTHON_BASE_IMAGE) \ + -f images/spyglass/Dockerfile.$(DISTRO) \ + $(_BASE_IMAGE_ARG) \ --build-arg ctx_base=$(SPYGLASS_BUILD_CTX) . endif ifeq ($(PUSH_IMAGE), true) diff --git a/images/spyglass/Dockerfile b/images/spyglass/Dockerfile.ubuntu_xenial similarity index 100% rename from images/spyglass/Dockerfile rename to images/spyglass/Dockerfile.ubuntu_xenial diff --git a/tools/gate/playbooks/docker-image-build.yaml b/tools/gate/playbooks/docker-image-build.yaml index 39e222b..bb6f026 100644 --- a/tools/gate/playbooks/docker-image-build.yaml +++ b/tools/gate/playbooks/docker-image-build.yaml @@ -22,6 +22,8 @@ var: publish - debug: var: tags + - debug: + var: distro - debug: var: zuul - debug: @@ -91,6 +93,7 @@ chdir: "{{ zuul.project.src_dir }}" target: images params: + DISTRO: "{{ distro }}" IMAGE_TAG: "{{ item }}" with_items: "{{ image_tags.stdout_lines }}" @@ -115,6 +118,7 @@ params: DOCKER_REGISTRY: "quay.io" IMAGE_PREFIX: "airshipit" + DISTRO: "{{ distro }}" IMAGE_TAG: "{{ item }}" COMMIT: "{{ zuul.newrev | default('') }}" PUSH_IMAGE: "true" diff --git a/tools/spyglass.sh b/tools/spyglass.sh index 7468227..7f7c792 100755 --- a/tools/spyglass.sh +++ b/tools/spyglass.sh @@ -3,7 +3,7 @@ set -e : ${WORKSPACE:=$(pwd)} -: ${IMAGE:=quay.io/airshipit/spyglass:latest} +: ${IMAGE:=quay.io/airshipit/spyglass:latest-ubuntu_xenial} : ${TERM_OPTS:=-t}