blob: 04450d63fbd4fe15da11f97d59c0d49dd5e4397a [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
4ARG TREX_VER=3b19ddcf67e33934f268b09d3364cd87275d48db
5ARG TREX_EXT_LIBS=/external_libs
6ARG TREX_LIBS=/trex_python
Yi Tsengaae6ef52021-09-01 13:48:27 -07007ARG KUBECTL=v1.22.1
Daniele Moroe734b7f2021-09-07 17:53:20 +02008
9# Install TRex deps
10FROM alpine:3.12.1 as trex-builder
11ARG TREX_VER
12ARG TREX_EXT_LIBS
13ARG TREX_LIBS
14# Install Trex library
15ENV TREX_SCRIPT_DIR=/trex-core-${TREX_VER}/scripts
16RUN wget https://github.com/stratum/trex-core/archive/${TREX_VER}.zip
17RUN 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
24FROM ubuntu:20.04
25ARG TREX_EXT_LIBS
26ARG TREX_LIBS
27ARG SCAPY_VER
28ARG KUBECTL
Yi Tsengaae6ef52021-09-01 13:48:27 -070029ENV PACKAGES \
30 python \
Daniele Moroe734b7f2021-09-07 17:53:20 +020031 python3 \
32 python3-pip \
Yi Tsengaae6ef52021-09-01 13:48:27 -070033 ssh \
34 openssh-server \
35 curl \
Daniele Moroe734b7f2021-09-07 17:53:20 +020036 supervisor \
Jon Halla4a79312022-01-25 17:16:53 -080037 git \
38 iproute2
Yi Tsengaae6ef52021-09-01 13:48:27 -070039ADD requirements.txt /
40
Daniele Moroe734b7f2021-09-07 17:53:20 +020041COPY --from=trex-builder /output /
42
Yi Tsengaae6ef52021-09-01 13:48:27 -070043RUN apt update && \
44 apt install --no-install-recommends -y $PACKAGES && \
45 curl -L "https://dl.k8s.io/release/$KUBECTL/bin/linux/amd64/kubectl" -o /usr/local/bin/kubectl && \
46 chmod 0755 /usr/local/bin/kubectl && \
Daniele Moroe734b7f2021-09-07 17:53:20 +020047 curl https://bootstrap.pypa.io/pip/2.7/get-pip.py | python && \
Yi Tsengaae6ef52021-09-01 13:48:27 -070048 python -m pip install setuptools && \
Daniele Moroe734b7f2021-09-07 17:53:20 +020049 python -m pip install -r requirements.txt && \
50 python3 -m pip install p4runtime-shell==0.0.2 && \
51 cd ${TREX_EXT_LIBS}/scapy-${SCAPY_VER} && python setup.py install && \
Yi Tsengaae6ef52021-09-01 13:48:27 -070052 mkdir -p /var/run/sshd && \
53 mkdir -p /var/log/supervisor && \
54 useradd -m jenkins && \
Daniele Moroc99bf822021-10-11 23:21:15 +020055 chmod 777 /tmp && \
Yi Tsengaae6ef52021-09-01 13:48:27 -070056 chsh -s /bin/bash jenkins && \
57 echo jenkins:jenkins | chpasswd
58
pierventreef5e1d12022-02-21 15:32:55 -080059ARG ENV
60
61RUN if [ "$ENV" = "linux" ] ; then groupmod --gid 1001 jenkins && usermod --uid 1001 jenkins ; fi
62
Daniele Moroc99bf822021-10-11 23:21:15 +020063RUN curl -sS --fail "https://repo1.maven.org/maven2/org/onosproject/onos-releases/2.5.4/onos-admin-2.5.4.tar.gz" | tar zx && \
64 mv onos-admin-2.5.4/* /usr/local/bin/ && \
65 rm -r onos-admin-2.5.4
66
Daniele Moroe734b7f2021-09-07 17:53:20 +020067ENV PYTHONPATH=${TREX_EXT_LIBS}:${TREX_LIBS}
68# TODO: should we parametrize those?
69ENV OC1=localhost
70ENV OC2=localhost
71ENV OC3=localhost
Yi Tsengaae6ef52021-09-01 13:48:27 -070072ADD docker/fs /
73RUN chown -R jenkins.jenkins /home/jenkins && \
74 python -m pip install -r /tmp/additional-py-pkgs.txt
75
76CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf"]
77
78EXPOSE 22