Add p4runtime shell and trex dependencies on Docker environment

Change-Id: Ic80a6cfe77d49c12890dc80e789492142a9716b3
diff --git a/TestON/docker/.gitignore b/TestON/docker/.gitignore
index ddbd53f..f0bcaa1 100644
--- a/TestON/docker/.gitignore
+++ b/TestON/docker/.gitignore
@@ -1,3 +1,4 @@
 fs/home/jenkins/*
+!fs/home/jenkins/.ipython
 fs/usr/local
 fs/tmp
diff --git a/TestON/docker/Dockerfile b/TestON/docker/Dockerfile
index 686d4fa..5ad5d52 100644
--- a/TestON/docker/Dockerfile
+++ b/TestON/docker/Dockerfile
@@ -1,29 +1,64 @@
 # SPDX-FileCopyrightText: Copyright 2021-present Open Networking Foundation.
 # SPDX-License-Identifier: Apache-2.0
-FROM ubuntu:18.04
-
+ARG SCAPY_VER=2.4.5
+ARG TREX_VER=3b19ddcf67e33934f268b09d3364cd87275d48db
+ARG TREX_EXT_LIBS=/external_libs
+ARG TREX_LIBS=/trex_python
 ARG KUBECTL=v1.22.1
+
+# Install TRex deps
+FROM alpine:3.12.1 as trex-builder
+ARG TREX_VER
+ARG TREX_EXT_LIBS
+ARG TREX_LIBS
+# Install Trex library
+ENV TREX_SCRIPT_DIR=/trex-core-${TREX_VER}/scripts
+RUN wget https://github.com/stratum/trex-core/archive/${TREX_VER}.zip
+RUN unzip -qq ${TREX_VER}.zip && \
+    mkdir -p /output/${TREX_EXT_LIBS} && \
+    mkdir -p /output/${TREX_LIBS} && \
+    cp -r ${TREX_SCRIPT_DIR}/automation/trex_control_plane/interactive/* /output/${TREX_LIBS} && \
+    cp -r ${TREX_SCRIPT_DIR}/external_libs/* /output/${TREX_EXT_LIBS} && \
+    cp -r ${TREX_SCRIPT_DIR}/automation/trex_control_plane/stf/trex_stf_lib /output/${TREX_LIBS}
+
+FROM ubuntu:20.04
+ARG TREX_EXT_LIBS
+ARG TREX_LIBS
+ARG SCAPY_VER
+ARG KUBECTL
 ENV PACKAGES \
     python \
-    python-pip \
+    python3 \
+    python3-pip \
     ssh \
     openssh-server \
     curl \
-    supervisor
+    supervisor \
+    git
 ADD requirements.txt /
 
+COPY --from=trex-builder /output /
+
 RUN apt update && \
     apt install --no-install-recommends -y $PACKAGES && \
     curl -L "https://dl.k8s.io/release/$KUBECTL/bin/linux/amd64/kubectl" -o /usr/local/bin/kubectl && \
     chmod 0755 /usr/local/bin/kubectl && \
+    curl https://bootstrap.pypa.io/pip/2.7/get-pip.py | python && \
     python -m pip install setuptools && \
-    python -m pip install -r requirements.txt && \
+    python -m pip install -r  requirements.txt && \
+    python3 -m pip install p4runtime-shell==0.0.2 && \
+    cd ${TREX_EXT_LIBS}/scapy-${SCAPY_VER} && python setup.py install && \
     mkdir -p /var/run/sshd && \
     mkdir -p /var/log/supervisor && \
     useradd -m jenkins && \
     chsh -s /bin/bash jenkins && \
     echo jenkins:jenkins | chpasswd
 
+ENV PYTHONPATH=${TREX_EXT_LIBS}:${TREX_LIBS}
+# TODO: should we parametrize those?
+ENV OC1=localhost
+ENV OC2=localhost
+ENV OC3=localhost
 ADD docker/fs /
 RUN chown -R jenkins.jenkins /home/jenkins && \
     python -m pip install -r /tmp/additional-py-pkgs.txt
diff --git a/TestON/docker/fs/home/jenkins/.ipython/profile_default/ipython_config.py b/TestON/docker/fs/home/jenkins/.ipython/profile_default/ipython_config.py
new file mode 100644
index 0000000..c59d906
--- /dev/null
+++ b/TestON/docker/fs/home/jenkins/.ipython/profile_default/ipython_config.py
@@ -0,0 +1,7 @@
+# Configure ipython to not use colors, helps the P4RuntimeCliDriver in getting
+# cleaner output
+# More info about configuration in: https://ipython.readthedocs.io/en/stable/config/options/terminal.html
+c.InteractiveShell.color_info = False
+c.InteractiveShell.colors = 'NoColor'
+c.TerminalInteractiveShell.color_info = False
+c.TerminalInteractiveShell.colors = 'NoColor'
\ No newline at end of file