Add Dockerfile to Infrared plugin

Change-Id: I0fcc0fcdca91c65099d2c3cf4122ef5035b19697
This commit is contained in:
Federico Ressi 2021-12-22 12:51:35 +01:00
parent ffaadf6436
commit 9876ce03d9
6 changed files with 78 additions and 58 deletions

View File

@ -49,3 +49,16 @@ services:
environment:
OS_TEST_PATH: tobiko/tests/sanity
TOX_REPORT_NAME: tobiko_results_verify_services
infrared:
build:
context: infrared_plugin
target: tobiko-infrared
hostname: tobiko-infrared
environment:
IR_EXTRA_ARGS: --tobiko-src-dir /tobiko
volumes:
- ./report:/report
- .:/tobiko
- ./infrared_plugin:/tobiko-infrared
- ~/.ssh:/root/.ssh

View File

@ -1,61 +1,52 @@
# Dockerfile that sets up InfraRed as documented here:
# https://infrared.readthedocs.io/en/latest/bootstrap.html#setup
FROM centos:8 as base
ARG base_image="docker.io/library/centos:8"
ENV TOBIKO_INFRARED_DIR /tobiko-infrared
ENV WHEEL_DIR /wheel
ENV REPORT_DIR /report
ENV IR_HOME /infrared
ENV IR_EXTRA_ARGS ""
FROM "${base_image}" AS infrared
# Install required binary dependencies
RUN dnf install -y git \
libselinux-python3 \
python3 \
rsync \
which && \
alternatives --set python /usr/bin/python3
# Get InfraRed sources with Git
ARG ir_src_dir=/src/infrared
ARG ir_git_url=https://github.com/redhat-openstack/infrared.git
ARG ir_git_refspec=master
ARG ir_git_remote=origin
RUN mkdir -p "${ir_src_dir}" && \
cd "${ir_src_dir}" && \
git init && \
git remote add "${ir_git_remote}" "${ir_git_url}" && \
git fetch "${ir_git_remote}" "${ir_git_refspec}" && \
git checkout FETCH_HEAD
WORKDIR "${ir_src_dir}"
ENV IR_HOME=/opt/infrared
# Install InfraRed and its default plugins
# - First installs infrared requirements to workaround the too-may-files
# problem related to temporary files removal final step
# - Then installs infrared itself
RUN python3 -m pip install --upgrade pip && \
python3 -m pip install --upgrade setuptools wheel && \
(python3 -m pip install . || python3 -m pip install .) && \
infrared plugin list && \
(python3 -m pip cache purge || true)
# Creates persistent volume for IR workspaces
VOLUME ${IR_HOME}/.workspaces
# Sets default entry point
ENTRYPOINT ["infrared"]
CMD ["--help"]
# Install common binary dependencies
RUN dnf install -y git python3 rsync which
RUN python3 -m pip install --upgrade wheel setuptools pip
# -----------------------------------------------------------------------------
FROM base as source
FROM infrared as tobiko_plugin
# Populate tobiko-infrared source dir
ADD . ${TOBIKO_INFRARED_DIR}
# Add Tobiko plugin directory
ARG ir_tobiko_plugin=${ir_tobiko_plugin:-/src/infrared-tobiko}
RUN mkdir -p "${ir_tobiko_plugin}"
ADD . "${ir_tobiko_plugin}"
# Installs Tobiko plugin
RUN infrared plugin add "${ir_tobiko_plugin}"
FROM source as build
# Sets tobiko as default command
CMD ["tobiko"]
# Build Infrared wheel files
RUN python3 -m pip wheel -w ${WHEEL_DIR} -r ${TOBIKO_INFRARED_DIR}/requirements.txt
FROM base as install
# Install wheels
RUN mkdir -p ${WHEEL_DIR}
COPY --from=build ${WHEEL_DIR} ${WHEEL_DIR}
RUN pip install ${WHEEL_DIR}/*.whl
FROM source as tobiko-infrared
# Creates directories
RUN mkdir -p "${IR_HOME}" "${REPORT_DIR}"
# Copy python pacakges
COPY --from=install /usr/local /usr/local/
# Add tobiko plugin
RUN infrared plugin add "${TOBIKO_INFRARED_DIR}"
# Create initial workspace
RUN infrared workspace checkout --create default
# Use infrared home dir as home
WORKDIR ${IR_HOME}
# Run Tobiko Infrared plugin
CMD infrared tobiko --collect-dir "${REPORT_DIR}" ${IR_EXTRA_ARGS}

View File

@ -4,5 +4,7 @@ docker_compose_command: run
docker_compose_dir: '{{ zuul_work_dir }}'
docker_compose_environment: {}
docker_compose_executable: /usr/local/bin/docker-compose
docker_compose_file: docker-compose.yml
docker_compose_execute:
"{{ docker_compose_executable }} -f '{{ docker_compose_file }}'"
zuul_work_dir: "{{ zuul.project.src_dir }}"

View File

@ -3,6 +3,6 @@
- name: "Build image for service {{ docker_compose_service }} at {{ docker_compose_dir }}"
command:
chdir: '{{ docker_compose_dir }}'
cmd: '{{ docker_compose_executable }} build {{ docker_compose_service }}'
cmd: '{{ docker_compose_execute }} build {{ docker_compose_service }}'
register: docker_compose_build
environment: '{{ docker_compose_environment }}'

View File

@ -3,6 +3,6 @@
- name: "Run service {{ docker_compose_service }} at {{ docker_compose_dir }}"
command:
chdir: '{{ docker_compose_dir }}'
cmd: '{{ docker_compose_executable }} run {{ docker_compose_service }}'
cmd: '{{ docker_compose_execute }} run {{ docker_compose_service }}'
register: docker_compose_run
environment: '{{ docker_compose_environment }}'

View File

@ -6,9 +6,12 @@
Docker jobs intended to gate Tobiko container related changes
check: &CHECK
jobs:
- tobiko-docker-unit
- tobiko-docker-functional
gate: *CHECK
- tobiko-docker-infrared
- tobiko-docker-unit
gate:
jobs:
- tobiko-docker-functional
periodic: *CHECK
@ -38,3 +41,14 @@
timeout: 3600
vars:
docker_compose_service: functional
- job:
name: tobiko-docker-infrared
description: |
Run functional tests for an OpenStack Python project inside a Docker container.
voting: false
parent: tobiko-docker-unit
timeout: 3600
vars:
docker_compose_service: infrared