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
This commit is contained in:
Hughes, Alexander (ah8742) 2019-06-07 14:01:35 +00:00
parent 6d72d7f9fc
commit 6cfe98e0c3
5 changed files with 36 additions and 24 deletions

View File

@ -18,15 +18,15 @@
check: check:
jobs: jobs:
- openstack-tox-pep8 - openstack-tox-pep8
- spyglass-docker-build-gate - spyglass-docker-build-gate-ubuntu_xenial
gate: gate:
jobs: jobs:
- openstack-tox-pep8 - openstack-tox-pep8
- spyglass-docker-build-gate - spyglass-docker-build-gate-ubuntu_xenial
post: post:
jobs: jobs:
- spyglass-docker-publish
- spyglass-upload-git-mirror - spyglass-upload-git-mirror
- spyglass-docker-publish-ubuntu_xenial
- nodeset: - nodeset:
name: spyglass-single-node name: spyglass-single-node
@ -35,25 +35,27 @@
label: ubuntu-xenial label: ubuntu-xenial
- job: - job:
name: spyglass-docker-build-gate name: spyglass-docker-build-gate-ubuntu_xenial
timeout: 1800 timeout: 1800
run: tools/gate/playbooks/docker-image-build.yaml run: tools/gate/playbooks/docker-image-build.yaml
nodeset: spyglass-single-node nodeset: spyglass-single-node
vars: vars:
publish: false publish: false
distro: ubuntu_xenial
tags: tags:
dynamic: dynamic:
patch_set: true patch_set: true
- job: - job:
name: spyglass-docker-publish name: spyglass-docker-publish-ubuntu_xenial
timeout: 1800 timeout: 1800
run: tools/gate/playbooks/docker-image-build.yaml run: tools/gate/playbooks/docker-image-build.yaml
nodeset: armada-single-node nodeset: spyglass-single-node
secrets: secrets:
- airship_spyglass_quay_creds - airship_spyglass_quay_creds
vars: vars:
publish: true publish: true
distro: ubuntu_xenial
tags: tags:
dynamic: dynamic:
branch: true branch: true

View File

@ -12,20 +12,24 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
SPYGLASS_BUILD_CTX ?= . SPYGLASS_BUILD_CTX ?= spyglass
IMAGE_NAME ?= spyglass IMAGE_NAME ?= spyglass
IMAGE_PREFIX ?= airshipit IMAGE_PREFIX ?= airshipit
DOCKER_REGISTRY ?= quay.io DOCKER_REGISTRY ?= quay.io
IMAGE_TAG ?= latest IMAGE_TAG ?= latest
PROXY ?= http://proxy.foo.com:8000 HELM ?= helm
NO_PROXY ?= localhost,127.0.0.1,.svc.cluster.local PROXY ?= http://proxy.foo.com:8000
USE_PROXY ?= false NO_PROXY ?= localhost,127.0.0.1,.svc.cluster.local
PUSH_IMAGE ?= false USE_PROXY ?= false
PUSH_IMAGE ?= false
# use this variable for image labels added in internal build process # use this variable for image labels added in internal build process
LABEL ?= org.airshipit.build=community LABEL ?= org.airshipit.build=community
COMMIT ?= $(shell git rev-parse HEAD) COMMIT ?= $(shell git rev-parse HEAD)
IMAGE ?= $(DOCKER_REGISTRY)/$(IMAGE_PREFIX)/$(IMAGE_NAME):$(IMAGE_TAG) DISTRO ?= ubuntu_xenial
PYTHON_BASE_IMAGE ?= python:3.6 IMAGE ?= $(DOCKER_REGISTRY)/$(IMAGE_PREFIX)/$(IMAGE_NAME):$(IMAGE_TAG)-${DISTRO}
PYTHON_BASE_IMAGE ?= python:3.6
BASE_IMAGE ?=
export export
# Build all docker images for this project # Build all docker images for this project
@ -55,6 +59,8 @@ lint: py_lint
.PHONY: format .PHONY: format
format: py_format format: py_format
_BASE_IMAGE_ARG := $(if $(BASE_IMAGE),--build-arg FROM="${BASE_IMAGE}" ,)
.PHONY: build_spyglass .PHONY: build_spyglass
build_spyglass: build_spyglass:
ifeq ($(USE_PROXY), true) ifeq ($(USE_PROXY), true)
@ -62,8 +68,8 @@ ifeq ($(USE_PROXY), true)
--label "org.opencontainers.image.revision=$(COMMIT)" \ --label "org.opencontainers.image.revision=$(COMMIT)" \
--label "org.opencontainers.image.created=$(shell date --rfc-3339=seconds --utc)" \ --label "org.opencontainers.image.created=$(shell date --rfc-3339=seconds --utc)" \
--label "org.opencontainers.image.title=$(IMAGE_NAME)" \ --label "org.opencontainers.image.title=$(IMAGE_NAME)" \
-f images/spyglass/Dockerfile \ -f images/spyglass/Dockerfile.$(DISTRO) \
--build-arg FROM=$(PYTHON_BASE_IMAGE) \ $(_BASE_IMAGE_ARG) \
--build-arg http_proxy=$(PROXY) \ --build-arg http_proxy=$(PROXY) \
--build-arg https_proxy=$(PROXY) \ --build-arg https_proxy=$(PROXY) \
--build-arg HTTP_PROXY=$(PROXY) \ --build-arg HTTP_PROXY=$(PROXY) \
@ -76,8 +82,8 @@ else
--label "org.opencontainers.image.revision=$(COMMIT)" \ --label "org.opencontainers.image.revision=$(COMMIT)" \
--label "org.opencontainers.image.created=$(shell date --rfc-3339=seconds --utc)" \ --label "org.opencontainers.image.created=$(shell date --rfc-3339=seconds --utc)" \
--label "org.opencontainers.image.title=$(IMAGE_NAME)" \ --label "org.opencontainers.image.title=$(IMAGE_NAME)" \
-f images/spyglass/Dockerfile \ -f images/spyglass/Dockerfile.$(DISTRO) \
--build-arg FROM=$(PYTHON_BASE_IMAGE) \ $(_BASE_IMAGE_ARG) \
--build-arg ctx_base=$(SPYGLASS_BUILD_CTX) . --build-arg ctx_base=$(SPYGLASS_BUILD_CTX) .
endif endif
ifeq ($(PUSH_IMAGE), true) ifeq ($(PUSH_IMAGE), true)

View File

@ -22,6 +22,8 @@
var: publish var: publish
- debug: - debug:
var: tags var: tags
- debug:
var: distro
- debug: - debug:
var: zuul var: zuul
- debug: - debug:
@ -91,6 +93,7 @@
chdir: "{{ zuul.project.src_dir }}" chdir: "{{ zuul.project.src_dir }}"
target: images target: images
params: params:
DISTRO: "{{ distro }}"
IMAGE_TAG: "{{ item }}" IMAGE_TAG: "{{ item }}"
with_items: "{{ image_tags.stdout_lines }}" with_items: "{{ image_tags.stdout_lines }}"
@ -115,6 +118,7 @@
params: params:
DOCKER_REGISTRY: "quay.io" DOCKER_REGISTRY: "quay.io"
IMAGE_PREFIX: "airshipit" IMAGE_PREFIX: "airshipit"
DISTRO: "{{ distro }}"
IMAGE_TAG: "{{ item }}" IMAGE_TAG: "{{ item }}"
COMMIT: "{{ zuul.newrev | default('') }}" COMMIT: "{{ zuul.newrev | default('') }}"
PUSH_IMAGE: "true" PUSH_IMAGE: "true"

View File

@ -3,7 +3,7 @@
set -e set -e
: ${WORKSPACE:=$(pwd)} : ${WORKSPACE:=$(pwd)}
: ${IMAGE:=quay.io/airshipit/spyglass:latest} : ${IMAGE:=quay.io/airshipit/spyglass:latest-ubuntu_xenial}
: ${TERM_OPTS:=-t} : ${TERM_OPTS:=-t}