|
1 | 1 | FROM quay.io/centos/centos:stream9 |
2 | 2 |
|
3 | | -# Update and use not only best candidate packages (avoiding failures) |
4 | | -RUN dnf update -y --nobest |
5 | | - |
6 | | -# Install development tools and necessary dependencies |
7 | | -RUN dnf group install -y "Development Tools" \ |
8 | | - && dnf install -y podman jq |
9 | | - |
10 | | -# Prerequisite for Python installation |
11 | | -ARG python_full_version=3.14.0 |
12 | | -RUN dnf install -y openssl-devel bzip2-devel wget libffi-devel |
13 | | - |
14 | | -# Install Python |
15 | | -RUN wget https://www.python.org/ftp/python/${python_full_version}/Python-${python_full_version}.tgz \ |
| 3 | +ARG python_version=3.14 |
| 4 | +ARG OCP_CLIENT_VERSION |
| 5 | +ARG VIRTCTL_VERSION |
| 6 | +ARG BENCHMARK_OPERATOR_VERSION=v1.0.4 |
| 7 | +ARG OPENSHIFT4_TOOLS_VERSION=v1.2.2-kata-ci |
| 8 | + |
| 9 | +ENV PYTHON_VERSION=${python_version} |
| 10 | + |
| 11 | +COPY hack/get_latest_python_patch.py /tmp/get_latest_python_patch.py |
| 12 | +RUN python_patch=$(python3 /tmp/get_latest_python_patch.py ${python_version}) \ |
| 13 | + && python_full_version=${python_version}.${python_patch} \ |
| 14 | + && dnf update -y --nobest \ |
| 15 | + && dnf group install -y "Development Tools" \ |
| 16 | + && dnf install -y podman jq openssl-devel bzip2-devel wget libffi-devel hostname bc procps-ng \ |
| 17 | + && wget https://www.python.org/ftp/python/${python_full_version}/Python-${python_full_version}.tgz \ |
16 | 18 | && tar -xzf Python-${python_full_version}.tgz \ |
17 | 19 | && cd Python-${python_full_version} \ |
18 | 20 | && ./configure --enable-optimizations \ |
19 | 21 | && make altinstall \ |
20 | | - && echo alias python=python3.14 >> ~/.bashrc \ |
21 | | - && rm -rf Python-${python_full_version}.tgz |
22 | | - |
23 | | -# install & run benchmark-runner (--no-cache-dir for take always the latest) |
24 | | -RUN python3.14 -m pip install --upgrade pip && python3.14 -m pip install --upgrade benchmark-runner |
25 | | - |
26 | | -# Passed dynamically |
27 | | -ARG OCP_CLIENT_VERSION |
28 | | -RUN curl -L "https://mirror.openshift.com/pub/openshift-v4/clients/ocp/${OCP_CLIENT_VERSION}/openshift-client-linux-${OCP_CLIENT_VERSION}.tar.gz" -o "/tmp/openshift-client-linux-${OCP_CLIENT_VERSION}.tar.gz" \ |
29 | | - && tar -xzvf /tmp/openshift-client-linux-${OCP_CLIENT_VERSION}.tar.gz -C /tmp/ \ |
30 | | - && mv /tmp/kubectl /usr/local/bin/kubectl \ |
31 | | - && mv /tmp/oc /usr/local/bin/oc \ |
32 | | - && rm -rf /tmp/openshift-client-linux-${OCP_CLIENT_VERSION}.tar.gz /tmp/kubectl /tmp/oc |
33 | | - |
34 | | -# Passed dynamically |
35 | | -ARG VIRTCTL_VERSION |
36 | | -RUN curl -L "https://github.com/kubevirt/kubevirt/releases/download/v${VIRTCTL_VERSION}/virtctl-v${VIRTCTL_VERSION}-linux-amd64" -o /usr/local/bin/virtctl \ |
37 | | - && chmod +x /usr/local/bin/virtctl |
38 | | - |
39 | | -# Activate root alias |
40 | | -RUN source ~/.bashrc |
41 | | - |
42 | | -# Create necessary directories with the correct permissions |
43 | | -RUN mkdir -p ~/.kube ~/.ssh /tmp/run_artifacts |
44 | | - |
45 | | -# download benchmark-operator to /tmp default path |
46 | | -RUN git clone -b v1.0.4 https://github.com/cloud-bulldozer/benchmark-operator /tmp/benchmark-operator |
47 | | - |
48 | | -# download clusterbuster to /tmp default path && install cluster-buster dependency |
49 | | -RUN git clone -b v1.2.2-kata-ci https://github.com/RobertKrawitz/OpenShift4-tools /tmp/OpenShift4-tools \ |
50 | | - && dnf install -y hostname bc procps-ng |
51 | | - |
52 | | -# Cleanup to reduce image size |
53 | | -RUN dnf clean all && rm -rf /var/cache/dnf |
| 22 | + && echo alias python=python${python_version} >> ~/.bashrc \ |
| 23 | + && cd .. \ |
| 24 | + && rm -rf Python-${python_full_version} Python-${python_full_version}.tgz \ |
| 25 | + && python${python_version} -m pip install --upgrade pip \ |
| 26 | + && python${python_version} -m pip install --upgrade benchmark-runner \ |
| 27 | + && curl -L "https://mirror.openshift.com/pub/openshift-v4/clients/ocp/${OCP_CLIENT_VERSION}/openshift-client-linux-${OCP_CLIENT_VERSION}.tar.gz" -o "/tmp/openshift-client-linux-${OCP_CLIENT_VERSION}.tar.gz" \ |
| 28 | + && tar -xzf /tmp/openshift-client-linux-${OCP_CLIENT_VERSION}.tar.gz -C /usr/local/bin kubectl oc \ |
| 29 | + && rm /tmp/openshift-client-linux-${OCP_CLIENT_VERSION}.tar.gz \ |
| 30 | + && curl -L "https://github.com/kubevirt/kubevirt/releases/download/v${VIRTCTL_VERSION}/virtctl-v${VIRTCTL_VERSION}-linux-amd64" -o /usr/local/bin/virtctl \ |
| 31 | + && chmod +x /usr/local/bin/virtctl \ |
| 32 | + && mkdir -p ~/.kube ~/.ssh /tmp/run_artifacts \ |
| 33 | + && git clone -b ${BENCHMARK_OPERATOR_VERSION} https://github.com/cloud-bulldozer/benchmark-operator /tmp/benchmark-operator \ |
| 34 | + && git clone -b ${OPENSHIFT4_TOOLS_VERSION} https://github.com/RobertKrawitz/OpenShift4-tools /tmp/OpenShift4-tools \ |
| 35 | + && dnf clean all \ |
| 36 | + && rm -rf /var/cache/dnf |
54 | 37 |
|
55 | 38 | # Add main |
56 | 39 | COPY benchmark_runner/main/main.py /benchmark_runner/main/main.py |
57 | 40 |
|
58 | | -CMD [ "python3.14", "/benchmark_runner/main/main.py"] |
| 41 | +# Shell form so PYTHON_VERSION is expanded; exec form would not expand ENV |
| 42 | +CMD ["/bin/sh", "-c", "exec python${PYTHON_VERSION} /benchmark_runner/main/main.py"] |
59 | 43 |
|
60 | 44 | # How to build the Dockerfile ? |
61 | | -# sudo podman build --build-arg OCP_CLIENT_VERSION=$OCP_CLIENT_VERSION--build-arg VIRTCTL_VERSION=$VIRTCTL_VERSION -t quay.io/benchmark-runner/benchmark-runner:latest . --no-cache |
| 45 | +# sudo podman build --build-arg OCP_CLIENT_VERSION=$OCP_CLIENT_VERSION --build-arg VIRTCTL_VERSION=$VIRTCTL_VERSION -t quay.io/benchmark-runner/benchmark-runner:latest . --no-cache |
62 | 46 | # sudo podman run --rm -it -v /root/.kube/:/root/.kube/ -v /etc/hosts:/etc/hosts --privileged quay.io/benchmark-runner/benchmark-runner:latest /bin/bash |
0 commit comments