From 6ee2aaf8450637c96b3f96ae6d5bca5ef8ac74a5 Mon Sep 17 00:00:00 2001 From: Rajeshwari Dharwadkar Date: Tue, 26 Feb 2019 20:04:59 -0800 Subject: [PATCH] Support pegleg to run on opensuse leap15 image Add DISTRO parameter to support multiple distros Add Dockerfile for opensuse to build leap 15 image. Change-Id: I7a529476937494e042a4801117489325aa6621c7 --- .zuul.yaml | 48 +++++++++++++++++-- Makefile | 15 ++++-- doc/source/cli/cli.rst | 2 +- doc/source/developer-overview.rst | 7 +-- images/pegleg/Dockerfile.opensuse_15 | 46 ++++++++++++++++++ .../{Dockerfile => Dockerfile.ubuntu_xenial} | 0 tools/gate/playbooks/docker-image-build.yaml | 4 ++ tools/pegleg.sh | 2 +- 8 files changed, 109 insertions(+), 15 deletions(-) create mode 100644 images/pegleg/Dockerfile.opensuse_15 rename images/pegleg/{Dockerfile => Dockerfile.ubuntu_xenial} (100%) diff --git a/.zuul.yaml b/.zuul.yaml index f87b3537..b14c2124 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -20,15 +20,18 @@ jobs: - openstack-tox-pep8 - airship-pegleg-doc-build - - airship-pegleg-docker-build-gate + - airship-pegleg-docker-build-gate-ubuntu + - airship-pegleg-docker-build-gate-opensuse gate: jobs: - openstack-tox-pep8 - airship-pegleg-doc-build - - airship-pegleg-docker-build-gate + - airship-pegleg-docker-build-gate-ubuntu + - airship-pegleg-docker-build-gate-opensuse post: jobs: - - airship-pegleg-docker-publish + - airship-pegleg-docker-publish-ubuntu + - airship-pegleg-docker-publish-opensuse - nodeset: name: airship-pegleg-single-node @@ -48,7 +51,7 @@ - ^setup.cfg$ - job: - name: airship-pegleg-docker-build-gate + name: airship-pegleg-docker-build-gate-ubuntu timeout: 1800 run: tools/gate/playbooks/docker-image-build.yaml nodeset: airship-pegleg-single-node @@ -56,12 +59,27 @@ - '^doc/.*' vars: publish: false + distro: ubuntu_xenial tags: dynamic: patch_set: true - job: - name: airship-pegleg-docker-publish + name: airship-pegleg-docker-build-gate-opensuse + timeout: 1800 + run: tools/gate/playbooks/docker-image-build.yaml + nodeset: airship-pegleg-single-node + irrelevant-files: + - '^doc/.*' + vars: + publish: false + distro: opensuse_15 + tags: + dynamic: + patch_set: true + +- job: + name: airship-pegleg-docker-publish-ubuntu timeout: 1800 run: tools/gate/playbooks/docker-image-build.yaml nodeset: airship-pegleg-single-node @@ -71,6 +89,26 @@ - '^doc/.*' vars: publish: true + distro: ubuntu_xenial + tags: + dynamic: + branch: true + commit: true + static: + - latest + +- job: + name: airship-pegleg-docker-publish-opensuse + timeout: 1800 + run: tools/gate/playbooks/docker-image-build.yaml + nodeset: airship-pegleg-single-node + secrets: + - airship_pegleg_quay_creds + irrelevant-files: + - '^doc/.*' + vars: + publish: true + distro: opensuse_15 tags: dynamic: branch: true diff --git a/Makefile b/Makefile index f2e71fcd..1b41f039 100644 --- a/Makefile +++ b/Makefile @@ -25,8 +25,11 @@ 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) +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 @@ -62,6 +65,8 @@ lint: py_lint .PHONY: format format: py_format +_BASE_IMAGE_ARG := $(if $(BASE_IMAGE),--build-arg FROM="${BASE_IMAGE}" ,) + .PHONY: build_pegleg build_pegleg: ifeq ($(USE_PROXY), true) @@ -69,8 +74,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/pegleg/Dockerfile \ - --build-arg FROM=$(PYTHON_BASE_IMAGE) \ + -f images/pegleg/Dockerfile.$(DISTRO) \ + $(_BASE_IMAGE_ARG) \ --build-arg http_proxy=$(PROXY) \ --build-arg https_proxy=$(PROXY) \ --build-arg HTTP_PROXY=$(PROXY) \ @@ -83,8 +88,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/pegleg/Dockerfile \ - --build-arg FROM=$(PYTHON_BASE_IMAGE) \ + -f images/pegleg/Dockerfile.$(DISTRO) \ + $(_BASE_IMAGE_ARG) \ --build-arg ctx_base=$(PEGLEG_BUILD_CTX) . endif ifeq ($(PUSH_IMAGE), true) diff --git a/doc/source/cli/cli.rst b/doc/source/cli/cli.rst index b8f43e54..602b9f61 100644 --- a/doc/source/cli/cli.rst +++ b/doc/source/cli/cli.rst @@ -41,7 +41,7 @@ Environment Variables $IMAGE = Location of pegleg docker image. - Example: $IMAGE=quay.io/airshipit/pegleg:latest + Example: $IMAGE=quay.io/airshipit/pegleg:latest-ubuntu_xenial Usage ===== diff --git a/doc/source/developer-overview.rst b/doc/source/developer-overview.rst index e5735ec6..f462f28d 100644 --- a/doc/source/developer-overview.rst +++ b/doc/source/developer-overview.rst @@ -77,9 +77,10 @@ The Pegleg code base lives under ``pegleg``. Pegleg supports py36 interpreter. Docker ------ -The Pegleg Dockerfile is located in ``/images/pegleg`` along with any -artifacts built specifically to enable the container image. Make targets are -used for generating and testing the artifacts. +Pegleg Dockerfiles for supported distributions are located in +``/images/pegleg`` along with any artifacts built specifically to enable the +container image. Make targets are used for generating and testing the +artifacts. * ``make images`` - Build the Pegleg Docker image. diff --git a/images/pegleg/Dockerfile.opensuse_15 b/images/pegleg/Dockerfile.opensuse_15 new file mode 100644 index 00000000..7564f86d --- /dev/null +++ b/images/pegleg/Dockerfile.opensuse_15 @@ -0,0 +1,46 @@ +ARG FROM=opensuse/leap:15.0 +FROM ${FROM} +ARG CFSSLURL=https://pkg.cfssl.org/R1.2/cfssl_linux-amd64 + +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-pegleg.readthedocs.org' +LABEL org.opencontainers.image.source='https://opendev.org/airship/pegleg' +LABEL org.opencontainers.image.vendor='The Airship Authors' +LABEL org.opencontainers.image.licenses='Apache-2.0' + +ENV LANG=C.UTF-8 +ENV LC_ALL=C.UTF-8 + +RUN set -x && \ + zypper up -y && \ + zypper --non-interactive install \ + git-core \ + which \ + gcc \ + curl \ + python3-devel \ + python3-setuptools \ + python3-dbm \ + python3-pip && \ + pip install --upgrade pip && \ + zypper clean -a && \ + rm -rf \ + /tmp/* \ + /var/tmp/* \ + /var/log/* \ + /usr/share/man \ + /usr/share/doc \ + /usr/share/doc-base + +VOLUME /var/pegleg +WORKDIR /var/pegleg + +COPY requirements.txt /opt/pegleg/requirements.txt +RUN pip3 install --no-cache-dir -r /opt/pegleg/requirements.txt + +COPY tools/install-cfssl.sh /opt/pegleg/tools/install-cfssl.sh +RUN /opt/pegleg/tools/install-cfssl.sh ${CFSSLURL} + +COPY . /opt/pegleg +RUN pip3 install -e /opt/pegleg diff --git a/images/pegleg/Dockerfile b/images/pegleg/Dockerfile.ubuntu_xenial similarity index 100% rename from images/pegleg/Dockerfile rename to images/pegleg/Dockerfile.ubuntu_xenial diff --git a/tools/gate/playbooks/docker-image-build.yaml b/tools/gate/playbooks/docker-image-build.yaml index 5421902b..62b112bc 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/pegleg.sh b/tools/pegleg.sh index ca75a335..173f346e 100755 --- a/tools/pegleg.sh +++ b/tools/pegleg.sh @@ -3,7 +3,7 @@ set -e : ${WORKSPACE:=$(pwd)} -: ${IMAGE:=quay.io/airshipit/pegleg:latest} +: ${IMAGE:=quay.io/airshipit/pegleg:latest-ubuntu_xenial} : ${TERM_OPTS:=-it}