Browse Source

Update Dockerfile to use bindep and tox

Change-Id: I1fd2e966863908751ab5cba685e99c1ddf07b582
changes/35/736935/2
Federico Ressi 8 months ago
parent
commit
69ea632d3e
4 changed files with 132 additions and 49 deletions
  1. +0
    -6
      .dockerignore
  2. +96
    -28
      Dockerfile
  3. +35
    -14
      docker-compose.yml
  4. +1
    -1
      tools/install-bindeps.sh

+ 0
- 6
.dockerignore View File

@ -37,11 +37,5 @@ doc/source/_static/config-samples/*.sample
Pipfile.lock
# Tobiko configuration file
tobiko.conf
clouds.yaml
ssh_config
# Infrared things
.infrared
workspace.tgz

+ 96
- 28
Dockerfile View File

@ -1,39 +1,107 @@
ARG base_image="docker.io/library/centos:8"
FROM "${base_image}" as tobiko
FROM "${base_image}" as base
# Install binary dependencies
RUN dnf install -y gcc git python3 python3-devel && \
alternatives --set python /usr/bin/python3
# Make sure Git and Python 3 are installed on your system.
RUN yum install -y git python3 rsync which
# Get Tobiko source files
ARG tobiko_src_dir=.
ENV TOBIKO_DIR=/src/tobiko
# Copy Tobiko source files
RUN mkdir /src
ADD "${tobiko_src_dir}" "${TOBIKO_DIR}"
WORKDIR "${TOBIKO_DIR}"
# Check your Python 3 version is greater than 3.6
RUN python3 -c 'import sys; sys.version_info >= (3, 6)'
# Install Python requirements
ARG constraints_file=https://opendev.org/openstack/requirements/raw/branch/master/upper-constraints.txt
ENV PIP_INSTALL="python -m pip install -c ${constraints_file}"
RUN set -x && \
python --version && \
${PIP_INSTALL} --upgrade pip && \
${PIP_INSTALL} --upgrade setuptools wheel && \
${PIP_INSTALL} -r ./requirements.txt && \
${PIP_INSTALL} ./
# Ensure Pip is installed and up-to date
RUN curl https://bootstrap.pypa.io/get-pip.py | python3
# Check installed Pip version
RUN python3 -m pip --version
# Ensure basic Python packages are installed and up-to-date
RUN python3 -m pip install --upgrade setuptools wheel virtualenv tox six
# Check installed Tox version
RUN tox --version
# -----------------------------------------------------------------------------
FROM base as sources
# Get Tobiko source code using Git
RUN mkdir -p /src
ADD . /src/tobiko
WORKDIR /src/tobiko
# -----------------------------------------------------------------------------
FROM sources as bindeps
# Ensure required binary packages are installed
RUN ./tools/install-bindeps.sh
# Check bindeps are installed
CMD tox -e bindeps
# -----------------------------------------------------------------------------
FROM bindeps as py3
# Prepare py3 Tox virtualenv
RUN tox -e py3 --notest
# Run unit yest cases
CMD tox -e py3
# -----------------------------------------------------------------------------
FROM py3 as venv
# Run bash inside py3 Tox environment
CMD tox -e venv
# -----------------------------------------------------------------------------
FROM py3 as functional
# Run functional test cases
CMD tox -e functional
# -----------------------------------------------------------------------------
FROM py3 as scenario
# Run scenario test cases
CMD tox -e scenario
# -----------------------------------------------------------------------------
FROM tobiko as tests
FROM py3 as neutron
# Run scenario test cases
CMD tox -e neutron
# -----------------------------------------------------------------------------
FROM py3 as faults
# Run faults test cases
CMD tox -e faults
# -----------------------------------------------------------------------------
from bindeps as infrared
# Set Python 3 as default alternative for python command
RUN alternatives --set python /usr/bin/python3
RUN ${PIP_INSTALL} -r ./test-requirements.txt
# Prepare infrared Tox virtualenv
RUN tox -e infrared --notest
# Run test cases
ENV OS_LOG_CAPTURE=true
ENV OS_STDOUT_CAPTURE=true
ENV OS_STDERR_CAPTURE=true
ENV OS_TEST_PATH=tobiko/tests/unit
ENTRYPOINT ./tools/run_tests.py
# Run Tobiko InfraRed plugin
CMD tox -e infrared

+ 35
- 14
docker-compose.yml View File

@ -2,31 +2,52 @@
version: '3.4'
services:
base:
build:
context: .
target: base
sources:
build:
context: .
target: sources
bindeps:
build:
context: .
target: bindeps
py3:
build:
context: .
target: tests
args:
OS_TEST_PATH: ./tests/unit
target: py3
venv:
build:
context: .
target: venv
functional:
build:
context: .
target: tests
args:
OS_TEST_PATH: ./tests/functional
target: functional
scenario:
build:
context: .
target: tests
args:
OS_TEST_PATH: ./tests/scenario
target: scenario
neutron:
build:
context: .
target: neutron
faults:
build:
context: .
target: tests
args:
OS_TEST_PATH: ./tests/faults
target: faults
infrared:
build:
context: ./infrared_plugin
target: tobiko_plugin
context: .
target: infrared

+ 1
- 1
tools/install-bindeps.sh View File

@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
set -ex


Loading…
Cancel
Save