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
This commit is contained in:
Rajeshwari Dharwadkar 2019-02-26 20:04:59 -08:00 committed by Arun Kant
parent 498d5c078f
commit 6ee2aaf845
8 changed files with 109 additions and 15 deletions

View File

@ -20,15 +20,18 @@
jobs: jobs:
- openstack-tox-pep8 - openstack-tox-pep8
- airship-pegleg-doc-build - airship-pegleg-doc-build
- airship-pegleg-docker-build-gate - airship-pegleg-docker-build-gate-ubuntu
- airship-pegleg-docker-build-gate-opensuse
gate: gate:
jobs: jobs:
- openstack-tox-pep8 - openstack-tox-pep8
- airship-pegleg-doc-build - airship-pegleg-doc-build
- airship-pegleg-docker-build-gate - airship-pegleg-docker-build-gate-ubuntu
- airship-pegleg-docker-build-gate-opensuse
post: post:
jobs: jobs:
- airship-pegleg-docker-publish - airship-pegleg-docker-publish-ubuntu
- airship-pegleg-docker-publish-opensuse
- nodeset: - nodeset:
name: airship-pegleg-single-node name: airship-pegleg-single-node
@ -48,7 +51,7 @@
- ^setup.cfg$ - ^setup.cfg$
- job: - job:
name: airship-pegleg-docker-build-gate name: airship-pegleg-docker-build-gate-ubuntu
timeout: 1800 timeout: 1800
run: tools/gate/playbooks/docker-image-build.yaml run: tools/gate/playbooks/docker-image-build.yaml
nodeset: airship-pegleg-single-node nodeset: airship-pegleg-single-node
@ -56,12 +59,27 @@
- '^doc/.*' - '^doc/.*'
vars: vars:
publish: false publish: false
distro: ubuntu_xenial
tags: tags:
dynamic: dynamic:
patch_set: true patch_set: true
- job: - 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 timeout: 1800
run: tools/gate/playbooks/docker-image-build.yaml run: tools/gate/playbooks/docker-image-build.yaml
nodeset: airship-pegleg-single-node nodeset: airship-pegleg-single-node
@ -71,6 +89,26 @@
- '^doc/.*' - '^doc/.*'
vars: vars:
publish: true 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: tags:
dynamic: dynamic:
branch: true branch: true

View File

@ -25,8 +25,11 @@ 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
IMAGE ?= $(DOCKER_REGISTRY)/$(IMAGE_PREFIX)/$(IMAGE_NAME):$(IMAGE_TAG)-${DISTRO}
PYTHON_BASE_IMAGE ?= python:3.6 PYTHON_BASE_IMAGE ?= python:3.6
BASE_IMAGE ?=
export export
# Build all docker images for this project # Build all docker images for this project
@ -62,6 +65,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_pegleg .PHONY: build_pegleg
build_pegleg: build_pegleg:
ifeq ($(USE_PROXY), true) ifeq ($(USE_PROXY), true)
@ -69,8 +74,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/pegleg/Dockerfile \ -f images/pegleg/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) \
@ -83,8 +88,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/pegleg/Dockerfile \ -f images/pegleg/Dockerfile.$(DISTRO) \
--build-arg FROM=$(PYTHON_BASE_IMAGE) \ $(_BASE_IMAGE_ARG) \
--build-arg ctx_base=$(PEGLEG_BUILD_CTX) . --build-arg ctx_base=$(PEGLEG_BUILD_CTX) .
endif endif
ifeq ($(PUSH_IMAGE), true) ifeq ($(PUSH_IMAGE), true)

View File

@ -41,7 +41,7 @@ Environment Variables
$IMAGE = Location of pegleg docker image. $IMAGE = Location of pegleg docker image.
Example: $IMAGE=quay.io/airshipit/pegleg:latest Example: $IMAGE=quay.io/airshipit/pegleg:latest-ubuntu_xenial
Usage Usage
===== =====

View File

@ -77,9 +77,10 @@ The Pegleg code base lives under ``pegleg``. Pegleg supports py36 interpreter.
Docker Docker
------ ------
The Pegleg Dockerfile is located in ``/images/pegleg`` along with any Pegleg Dockerfiles for supported distributions are located in
artifacts built specifically to enable the container image. Make targets are ``/images/pegleg`` along with any artifacts built specifically to enable the
used for generating and testing the artifacts. container image. Make targets are used for generating and testing the
artifacts.
* ``make images`` - Build the Pegleg Docker image. * ``make images`` - Build the Pegleg Docker image.

View File

@ -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

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/pegleg:latest} : ${IMAGE:=quay.io/airshipit/pegleg:latest-ubuntu_xenial}
: ${TERM_OPTS:=-it} : ${TERM_OPTS:=-it}