Yi Tseng | aae6ef5 | 2021-09-01 13:48:27 -0700 | [diff] [blame] | 1 | # SPDX-FileCopyrightText: Copyright 2021-present Open Networking Foundation. |
| 2 | # SPDX-License-Identifier: Apache-2.0 |
Daniele Moro | e734b7f | 2021-09-07 17:53:20 +0200 | [diff] [blame] | 3 | ARG SCAPY_VER=2.4.5 |
| 4 | ARG TREX_VER=3b19ddcf67e33934f268b09d3364cd87275d48db |
| 5 | ARG TREX_EXT_LIBS=/external_libs |
| 6 | ARG TREX_LIBS=/trex_python |
Yi Tseng | aae6ef5 | 2021-09-01 13:48:27 -0700 | [diff] [blame] | 7 | ARG KUBECTL=v1.22.1 |
Daniele Moro | e734b7f | 2021-09-07 17:53:20 +0200 | [diff] [blame] | 8 | |
| 9 | # Install TRex deps |
| 10 | FROM alpine:3.12.1 as trex-builder |
| 11 | ARG TREX_VER |
| 12 | ARG TREX_EXT_LIBS |
| 13 | ARG TREX_LIBS |
| 14 | # Install Trex library |
| 15 | ENV TREX_SCRIPT_DIR=/trex-core-${TREX_VER}/scripts |
| 16 | RUN wget https://github.com/stratum/trex-core/archive/${TREX_VER}.zip |
| 17 | RUN unzip -qq ${TREX_VER}.zip && \ |
| 18 | mkdir -p /output/${TREX_EXT_LIBS} && \ |
| 19 | mkdir -p /output/${TREX_LIBS} && \ |
| 20 | cp -r ${TREX_SCRIPT_DIR}/automation/trex_control_plane/interactive/* /output/${TREX_LIBS} && \ |
| 21 | cp -r ${TREX_SCRIPT_DIR}/external_libs/* /output/${TREX_EXT_LIBS} && \ |
| 22 | cp -r ${TREX_SCRIPT_DIR}/automation/trex_control_plane/stf/trex_stf_lib /output/${TREX_LIBS} |
| 23 | |
| 24 | FROM ubuntu:20.04 |
| 25 | ARG TREX_EXT_LIBS |
| 26 | ARG TREX_LIBS |
| 27 | ARG SCAPY_VER |
| 28 | ARG KUBECTL |
Yi Tseng | aae6ef5 | 2021-09-01 13:48:27 -0700 | [diff] [blame] | 29 | ENV PACKAGES \ |
| 30 | python \ |
Daniele Moro | e734b7f | 2021-09-07 17:53:20 +0200 | [diff] [blame] | 31 | python3 \ |
| 32 | python3-pip \ |
Yi Tseng | aae6ef5 | 2021-09-01 13:48:27 -0700 | [diff] [blame] | 33 | ssh \ |
| 34 | openssh-server \ |
| 35 | curl \ |
Daniele Moro | e734b7f | 2021-09-07 17:53:20 +0200 | [diff] [blame] | 36 | supervisor \ |
| 37 | git |
Yi Tseng | aae6ef5 | 2021-09-01 13:48:27 -0700 | [diff] [blame] | 38 | ADD requirements.txt / |
| 39 | |
Daniele Moro | e734b7f | 2021-09-07 17:53:20 +0200 | [diff] [blame] | 40 | COPY --from=trex-builder /output / |
| 41 | |
Yi Tseng | aae6ef5 | 2021-09-01 13:48:27 -0700 | [diff] [blame] | 42 | RUN apt update && \ |
| 43 | apt install --no-install-recommends -y $PACKAGES && \ |
| 44 | curl -L "https://dl.k8s.io/release/$KUBECTL/bin/linux/amd64/kubectl" -o /usr/local/bin/kubectl && \ |
| 45 | chmod 0755 /usr/local/bin/kubectl && \ |
Daniele Moro | e734b7f | 2021-09-07 17:53:20 +0200 | [diff] [blame] | 46 | curl https://bootstrap.pypa.io/pip/2.7/get-pip.py | python && \ |
Yi Tseng | aae6ef5 | 2021-09-01 13:48:27 -0700 | [diff] [blame] | 47 | python -m pip install setuptools && \ |
Daniele Moro | e734b7f | 2021-09-07 17:53:20 +0200 | [diff] [blame] | 48 | python -m pip install -r requirements.txt && \ |
| 49 | python3 -m pip install p4runtime-shell==0.0.2 && \ |
| 50 | cd ${TREX_EXT_LIBS}/scapy-${SCAPY_VER} && python setup.py install && \ |
Yi Tseng | aae6ef5 | 2021-09-01 13:48:27 -0700 | [diff] [blame] | 51 | mkdir -p /var/run/sshd && \ |
| 52 | mkdir -p /var/log/supervisor && \ |
| 53 | useradd -m jenkins && \ |
Daniele Moro | c99bf82 | 2021-10-11 23:21:15 +0200 | [diff] [blame] | 54 | chmod 777 /tmp && \ |
Yi Tseng | aae6ef5 | 2021-09-01 13:48:27 -0700 | [diff] [blame] | 55 | chsh -s /bin/bash jenkins && \ |
| 56 | echo jenkins:jenkins | chpasswd |
| 57 | |
Daniele Moro | c99bf82 | 2021-10-11 23:21:15 +0200 | [diff] [blame] | 58 | RUN curl -sS --fail "https://repo1.maven.org/maven2/org/onosproject/onos-releases/2.5.4/onos-admin-2.5.4.tar.gz" | tar zx && \ |
| 59 | mv onos-admin-2.5.4/* /usr/local/bin/ && \ |
| 60 | rm -r onos-admin-2.5.4 |
| 61 | |
Daniele Moro | e734b7f | 2021-09-07 17:53:20 +0200 | [diff] [blame] | 62 | ENV PYTHONPATH=${TREX_EXT_LIBS}:${TREX_LIBS} |
| 63 | # TODO: should we parametrize those? |
| 64 | ENV OC1=localhost |
| 65 | ENV OC2=localhost |
| 66 | ENV OC3=localhost |
Yi Tseng | aae6ef5 | 2021-09-01 13:48:27 -0700 | [diff] [blame] | 67 | ADD docker/fs / |
| 68 | RUN chown -R jenkins.jenkins /home/jenkins && \ |
| 69 | python -m pip install -r /tmp/additional-py-pkgs.txt |
| 70 | |
| 71 | CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf"] |
| 72 | |
| 73 | EXPOSE 22 |