blob: 5ad5d528f6f31f8b98679422c6fc2e62ea10b00b [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 \
37 git
Yi Tsengaae6ef52021-09-01 13:48:27 -070038ADD requirements.txt /
39
Daniele Moroe734b7f2021-09-07 17:53:20 +020040COPY --from=trex-builder /output /
41
Yi Tsengaae6ef52021-09-01 13:48:27 -070042RUN 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 Moroe734b7f2021-09-07 17:53:20 +020046 curl https://bootstrap.pypa.io/pip/2.7/get-pip.py | python && \
Yi Tsengaae6ef52021-09-01 13:48:27 -070047 python -m pip install setuptools && \
Daniele Moroe734b7f2021-09-07 17:53:20 +020048 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 Tsengaae6ef52021-09-01 13:48:27 -070051 mkdir -p /var/run/sshd && \
52 mkdir -p /var/log/supervisor && \
53 useradd -m jenkins && \
54 chsh -s /bin/bash jenkins && \
55 echo jenkins:jenkins | chpasswd
56
Daniele Moroe734b7f2021-09-07 17:53:20 +020057ENV PYTHONPATH=${TREX_EXT_LIBS}:${TREX_LIBS}
58# TODO: should we parametrize those?
59ENV OC1=localhost
60ENV OC2=localhost
61ENV OC3=localhost
Yi Tsengaae6ef52021-09-01 13:48:27 -070062ADD docker/fs /
63RUN chown -R jenkins.jenkins /home/jenkins && \
64 python -m pip install -r /tmp/additional-py-pkgs.txt
65
66CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf"]
67
68EXPOSE 22