blob: a8cf1ec358ba6fb94cfaee338183f3d49850c3e2 [file] [log] [blame]
Yi Tsengaae6ef52021-09-01 13:48:27 -07001# SPDX-FileCopyrightText: Copyright 2021-present Open Networking Foundation.
2# SPDX-License-Identifier: Apache-2.0
Daniele Moroe734b7f2021-09-07 17:53:20 +02003ARG SCAPY_VER=2.4.5
Tseng, Yic76c21d2022-06-07 12:54:49 -07004ARG TREX_VER=3532cf99daf6dd3a1a284d0f1c388f1773eadc8a
Daniele Moroe734b7f2021-09-07 17:53:20 +02005ARG TREX_EXT_LIBS=/external_libs
6ARG TREX_LIBS=/trex_python
Yi Tsengaae6ef52021-09-01 13:48:27 -07007ARG KUBECTL=v1.22.1
Tseng, Yi8610c142022-05-31 09:41:31 -07008ARG ONOS_VER=2.5.4
9ARG RANCHER_VER=2.6.5
10ARG GO_VER=1.18.2
11ARG TFMASK_VER=0.7.0
Daniele Moroe734b7f2021-09-07 17:53:20 +020012
13# Install TRex deps
14FROM alpine:3.12.1 as trex-builder
15ARG TREX_VER
16ARG TREX_EXT_LIBS
17ARG TREX_LIBS
18# Install Trex library
19ENV TREX_SCRIPT_DIR=/trex-core-${TREX_VER}/scripts
20RUN wget https://github.com/stratum/trex-core/archive/${TREX_VER}.zip
21RUN 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
28FROM ubuntu:20.04
29ARG TREX_EXT_LIBS
30ARG TREX_LIBS
31ARG SCAPY_VER
32ARG KUBECTL
Tseng, Yi8610c142022-05-31 09:41:31 -070033ARG JENKINS_URL
34ARG JENKINS_NODE
35ARG ONOS_VER
36ARG RANCHER_VER
37ARG GO_VER
38ARG TFMASK_VER
39ENV DEBIAN_FRONTEND=noninteractive
Yi Tsengaae6ef52021-09-01 13:48:27 -070040ENV PACKAGES \
41 python \
Daniele Moroe734b7f2021-09-07 17:53:20 +020042 python3 \
43 python3-pip \
Yi Tsengaae6ef52021-09-01 13:48:27 -070044 ssh \
45 openssh-server \
46 curl \
Daniele Moroe734b7f2021-09-07 17:53:20 +020047 supervisor \
Jon Halla4a79312022-01-25 17:16:53 -080048 git \
Tseng, Yi8610c142022-05-31 09:41:31 -070049 iproute2 \
50 openjdk-11-jre \
51 software-properties-common \
52 git-crypt \
Tseng, Yic76c21d2022-06-07 12:54:49 -070053 gnupg-agent \
54 sudo
Yi Tsengaae6ef52021-09-01 13:48:27 -070055ADD requirements.txt /
56
Daniele Moroe734b7f2021-09-07 17:53:20 +020057COPY --from=trex-builder /output /
58
Yi Tsengaae6ef52021-09-01 13:48:27 -070059RUN apt update && \
60 apt install --no-install-recommends -y $PACKAGES && \
61 curl -L "https://dl.k8s.io/release/$KUBECTL/bin/linux/amd64/kubectl" -o /usr/local/bin/kubectl && \
62 chmod 0755 /usr/local/bin/kubectl && \
Daniele Moroe734b7f2021-09-07 17:53:20 +020063 curl https://bootstrap.pypa.io/pip/2.7/get-pip.py | python && \
Yi Tsengaae6ef52021-09-01 13:48:27 -070064 python -m pip install setuptools && \
Daniele Moroe734b7f2021-09-07 17:53:20 +020065 python -m pip install -r requirements.txt && \
66 python3 -m pip install p4runtime-shell==0.0.2 && \
67 cd ${TREX_EXT_LIBS}/scapy-${SCAPY_VER} && python setup.py install && \
Yi Tsengaae6ef52021-09-01 13:48:27 -070068 mkdir -p /var/run/sshd && \
69 mkdir -p /var/log/supervisor && \
Tseng, Yic76c21d2022-06-07 12:54:49 -070070 useradd -m jenkins -G sudo && \
Daniele Moroc99bf822021-10-11 23:21:15 +020071 chmod 777 /tmp && \
Yi Tsengaae6ef52021-09-01 13:48:27 -070072 chsh -s /bin/bash jenkins && \
73 echo jenkins:jenkins | chpasswd
74
pierventreef5e1d12022-02-21 15:32:55 -080075ARG ENV
76
77RUN if [ "$ENV" = "linux" ] ; then groupmod --gid 1001 jenkins && usermod --uid 1001 jenkins ; fi
78
Tseng, Yi8610c142022-05-31 09:41:31 -070079RUN curl -sS --fail "https://repo1.maven.org/maven2/org/onosproject/onos-releases/${ONOS_VER}/onos-admin-${ONOS_VER}.tar.gz" | tar zx && \
80 mv onos-admin-${ONOS_VER}/* /usr/local/bin/ && \
81 rm -r onos-admin-${ONOS_VER}
82
83RUN curl -L -sS --fail "https://github.com/rancher/cli/releases/download/v${RANCHER_VER}/rancher-linux-amd64-v${RANCHER_VER}.tar.gz" | tar zx && \
84 mv rancher-v${RANCHER_VER}/rancher /usr/local/bin && \
85 rm -r rancher-v${RANCHER_VER}
86
87RUN cd /usr/local && curl -L -sS --fail https://go.dev/dl/go${GO_VER}.linux-amd64.tar.gz | tar zx
88ENV PATH=$PATH:/usr/local/go/bin
89
90RUN curl -fsSL https://apt.releases.hashicorp.com/gpg | apt-key add - && \
91 apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main" && \
92 apt-get update && apt-get install terraform
93
94RUN curl -Lo /usr/local/bin/tfmask https://github.com/cloudposse/tfmask/releases/download/${TFMASK_VER}/tfmask_linux_amd64 && \
Tseng, Yic76c21d2022-06-07 12:54:49 -070095 chmod +x /usr/local/bin/tfmask
96RUN ln -s /trex_python /home/jenkins/trex_python
97RUN echo '%jenkins ALL=(ALL:ALL) NOPASSWD:ALL' >> /etc/sudoers
Daniele Moroc99bf822021-10-11 23:21:15 +020098
Daniele Moroe734b7f2021-09-07 17:53:20 +020099ENV PYTHONPATH=${TREX_EXT_LIBS}:${TREX_LIBS}
100# TODO: should we parametrize those?
101ENV OC1=localhost
102ENV OC2=localhost
103ENV OC3=localhost
Yi Tsengaae6ef52021-09-01 13:48:27 -0700104ADD docker/fs /
105RUN chown -R jenkins.jenkins /home/jenkins && \
Tseng, Yi8610c142022-05-31 09:41:31 -0700106 python -m pip install -r /tmp/additional-py-pkgs.txt && \
107 chmod 1777 /tmp
108ENV JENKINS_URL=${JENKINS_URL}
109ENV JENKINS_NODE=${JENKINS_NODE}
Yi Tsengaae6ef52021-09-01 13:48:27 -0700110
111CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf"]
112
113EXPOSE 22