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 |
Tseng, Yi | 8610c14 | 2022-05-31 09:41:31 -0700 | [diff] [blame] | 8 | ARG ONOS_VER=2.5.4 |
| 9 | ARG RANCHER_VER=2.6.5 |
| 10 | ARG GO_VER=1.18.2 |
| 11 | ARG TFMASK_VER=0.7.0 |
Daniele Moro | e734b7f | 2021-09-07 17:53:20 +0200 | [diff] [blame] | 12 | |
| 13 | # Install TRex deps |
| 14 | FROM alpine:3.12.1 as trex-builder |
| 15 | ARG TREX_VER |
| 16 | ARG TREX_EXT_LIBS |
| 17 | ARG TREX_LIBS |
| 18 | # Install Trex library |
| 19 | ENV TREX_SCRIPT_DIR=/trex-core-${TREX_VER}/scripts |
| 20 | RUN wget https://github.com/stratum/trex-core/archive/${TREX_VER}.zip |
| 21 | RUN unzip -qq ${TREX_VER}.zip && \ |
| 22 | mkdir -p /output/${TREX_EXT_LIBS} && \ |
| 23 | mkdir -p /output/${TREX_LIBS} && \ |
| 24 | cp -r ${TREX_SCRIPT_DIR}/automation/trex_control_plane/interactive/* /output/${TREX_LIBS} && \ |
| 25 | cp -r ${TREX_SCRIPT_DIR}/external_libs/* /output/${TREX_EXT_LIBS} && \ |
| 26 | cp -r ${TREX_SCRIPT_DIR}/automation/trex_control_plane/stf/trex_stf_lib /output/${TREX_LIBS} |
| 27 | |
| 28 | FROM ubuntu:20.04 |
| 29 | ARG TREX_EXT_LIBS |
| 30 | ARG TREX_LIBS |
| 31 | ARG SCAPY_VER |
| 32 | ARG KUBECTL |
Tseng, Yi | 8610c14 | 2022-05-31 09:41:31 -0700 | [diff] [blame] | 33 | ARG JENKINS_URL |
| 34 | ARG JENKINS_NODE |
| 35 | ARG ONOS_VER |
| 36 | ARG RANCHER_VER |
| 37 | ARG GO_VER |
| 38 | ARG TFMASK_VER |
| 39 | ENV DEBIAN_FRONTEND=noninteractive |
Yi Tseng | aae6ef5 | 2021-09-01 13:48:27 -0700 | [diff] [blame] | 40 | ENV PACKAGES \ |
| 41 | python \ |
Daniele Moro | e734b7f | 2021-09-07 17:53:20 +0200 | [diff] [blame] | 42 | python3 \ |
| 43 | python3-pip \ |
Yi Tseng | aae6ef5 | 2021-09-01 13:48:27 -0700 | [diff] [blame] | 44 | ssh \ |
| 45 | openssh-server \ |
| 46 | curl \ |
Daniele Moro | e734b7f | 2021-09-07 17:53:20 +0200 | [diff] [blame] | 47 | supervisor \ |
Jon Hall | a4a7931 | 2022-01-25 17:16:53 -0800 | [diff] [blame] | 48 | git \ |
Tseng, Yi | 8610c14 | 2022-05-31 09:41:31 -0700 | [diff] [blame] | 49 | iproute2 \ |
| 50 | openjdk-11-jre \ |
| 51 | software-properties-common \ |
| 52 | git-crypt \ |
| 53 | gnupg-agent |
Yi Tseng | aae6ef5 | 2021-09-01 13:48:27 -0700 | [diff] [blame] | 54 | ADD requirements.txt / |
| 55 | |
Daniele Moro | e734b7f | 2021-09-07 17:53:20 +0200 | [diff] [blame] | 56 | COPY --from=trex-builder /output / |
| 57 | |
Yi Tseng | aae6ef5 | 2021-09-01 13:48:27 -0700 | [diff] [blame] | 58 | RUN apt update && \ |
| 59 | apt install --no-install-recommends -y $PACKAGES && \ |
| 60 | curl -L "https://dl.k8s.io/release/$KUBECTL/bin/linux/amd64/kubectl" -o /usr/local/bin/kubectl && \ |
| 61 | chmod 0755 /usr/local/bin/kubectl && \ |
Daniele Moro | e734b7f | 2021-09-07 17:53:20 +0200 | [diff] [blame] | 62 | curl https://bootstrap.pypa.io/pip/2.7/get-pip.py | python && \ |
Yi Tseng | aae6ef5 | 2021-09-01 13:48:27 -0700 | [diff] [blame] | 63 | python -m pip install setuptools && \ |
Daniele Moro | e734b7f | 2021-09-07 17:53:20 +0200 | [diff] [blame] | 64 | python -m pip install -r requirements.txt && \ |
| 65 | python3 -m pip install p4runtime-shell==0.0.2 && \ |
| 66 | cd ${TREX_EXT_LIBS}/scapy-${SCAPY_VER} && python setup.py install && \ |
Yi Tseng | aae6ef5 | 2021-09-01 13:48:27 -0700 | [diff] [blame] | 67 | mkdir -p /var/run/sshd && \ |
| 68 | mkdir -p /var/log/supervisor && \ |
| 69 | useradd -m jenkins && \ |
Daniele Moro | c99bf82 | 2021-10-11 23:21:15 +0200 | [diff] [blame] | 70 | chmod 777 /tmp && \ |
Yi Tseng | aae6ef5 | 2021-09-01 13:48:27 -0700 | [diff] [blame] | 71 | chsh -s /bin/bash jenkins && \ |
| 72 | echo jenkins:jenkins | chpasswd |
| 73 | |
pierventre | ef5e1d1 | 2022-02-21 15:32:55 -0800 | [diff] [blame] | 74 | ARG ENV |
| 75 | |
| 76 | RUN if [ "$ENV" = "linux" ] ; then groupmod --gid 1001 jenkins && usermod --uid 1001 jenkins ; fi |
| 77 | |
Tseng, Yi | 8610c14 | 2022-05-31 09:41:31 -0700 | [diff] [blame] | 78 | RUN curl -sS --fail "https://repo1.maven.org/maven2/org/onosproject/onos-releases/${ONOS_VER}/onos-admin-${ONOS_VER}.tar.gz" | tar zx && \ |
| 79 | mv onos-admin-${ONOS_VER}/* /usr/local/bin/ && \ |
| 80 | rm -r onos-admin-${ONOS_VER} |
| 81 | |
| 82 | RUN curl -L -sS --fail "https://github.com/rancher/cli/releases/download/v${RANCHER_VER}/rancher-linux-amd64-v${RANCHER_VER}.tar.gz" | tar zx && \ |
| 83 | mv rancher-v${RANCHER_VER}/rancher /usr/local/bin && \ |
| 84 | rm -r rancher-v${RANCHER_VER} |
| 85 | |
| 86 | RUN cd /usr/local && curl -L -sS --fail https://go.dev/dl/go${GO_VER}.linux-amd64.tar.gz | tar zx |
| 87 | ENV PATH=$PATH:/usr/local/go/bin |
| 88 | |
| 89 | RUN curl -fsSL https://apt.releases.hashicorp.com/gpg | apt-key add - && \ |
| 90 | apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main" && \ |
| 91 | apt-get update && apt-get install terraform |
| 92 | |
| 93 | RUN curl -Lo /usr/local/bin/tfmask https://github.com/cloudposse/tfmask/releases/download/${TFMASK_VER}/tfmask_linux_amd64 && \ |
| 94 | chmod +x /usr/local/bin/tfmask |
Daniele Moro | c99bf82 | 2021-10-11 23:21:15 +0200 | [diff] [blame] | 95 | |
Daniele Moro | e734b7f | 2021-09-07 17:53:20 +0200 | [diff] [blame] | 96 | ENV PYTHONPATH=${TREX_EXT_LIBS}:${TREX_LIBS} |
| 97 | # TODO: should we parametrize those? |
| 98 | ENV OC1=localhost |
| 99 | ENV OC2=localhost |
| 100 | ENV OC3=localhost |
Yi Tseng | aae6ef5 | 2021-09-01 13:48:27 -0700 | [diff] [blame] | 101 | ADD docker/fs / |
| 102 | RUN chown -R jenkins.jenkins /home/jenkins && \ |
Tseng, Yi | 8610c14 | 2022-05-31 09:41:31 -0700 | [diff] [blame] | 103 | python -m pip install -r /tmp/additional-py-pkgs.txt && \ |
| 104 | chmod 1777 /tmp |
| 105 | ENV JENKINS_URL=${JENKINS_URL} |
| 106 | ENV JENKINS_NODE=${JENKINS_NODE} |
Yi Tseng | aae6ef5 | 2021-09-01 13:48:27 -0700 | [diff] [blame] | 107 | |
| 108 | CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf"] |
| 109 | |
| 110 | EXPOSE 22 |