blob: a17238ff580f856c5906228e7da448af38f8a60d [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
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 \
53 gnupg-agent
Yi Tsengaae6ef52021-09-01 13:48:27 -070054ADD requirements.txt /
55
Daniele Moroe734b7f2021-09-07 17:53:20 +020056COPY --from=trex-builder /output /
57
Yi Tsengaae6ef52021-09-01 13:48:27 -070058RUN 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 Moroe734b7f2021-09-07 17:53:20 +020062 curl https://bootstrap.pypa.io/pip/2.7/get-pip.py | python && \
Yi Tsengaae6ef52021-09-01 13:48:27 -070063 python -m pip install setuptools && \
Daniele Moroe734b7f2021-09-07 17:53:20 +020064 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 Tsengaae6ef52021-09-01 13:48:27 -070067 mkdir -p /var/run/sshd && \
68 mkdir -p /var/log/supervisor && \
69 useradd -m jenkins && \
Daniele Moroc99bf822021-10-11 23:21:15 +020070 chmod 777 /tmp && \
Yi Tsengaae6ef52021-09-01 13:48:27 -070071 chsh -s /bin/bash jenkins && \
72 echo jenkins:jenkins | chpasswd
73
pierventreef5e1d12022-02-21 15:32:55 -080074ARG ENV
75
76RUN if [ "$ENV" = "linux" ] ; then groupmod --gid 1001 jenkins && usermod --uid 1001 jenkins ; fi
77
Tseng, Yi8610c142022-05-31 09:41:31 -070078RUN 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
82RUN 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
86RUN cd /usr/local && curl -L -sS --fail https://go.dev/dl/go${GO_VER}.linux-amd64.tar.gz | tar zx
87ENV PATH=$PATH:/usr/local/go/bin
88
89RUN 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
93RUN 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 Moroc99bf822021-10-11 23:21:15 +020095
Daniele Moroe734b7f2021-09-07 17:53:20 +020096ENV PYTHONPATH=${TREX_EXT_LIBS}:${TREX_LIBS}
97# TODO: should we parametrize those?
98ENV OC1=localhost
99ENV OC2=localhost
100ENV OC3=localhost
Yi Tsengaae6ef52021-09-01 13:48:27 -0700101ADD docker/fs /
102RUN chown -R jenkins.jenkins /home/jenkins && \
Tseng, Yi8610c142022-05-31 09:41:31 -0700103 python -m pip install -r /tmp/additional-py-pkgs.txt && \
104 chmod 1777 /tmp
105ENV JENKINS_URL=${JENKINS_URL}
106ENV JENKINS_NODE=${JENKINS_NODE}
Yi Tsengaae6ef52021-09-01 13:48:27 -0700107
108CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf"]
109
110EXPOSE 22