blob: 5daca448bacf1acf8da5192fd91058a10abf70fa [file] [log] [blame]
Andrew Geissler0205e8d2016-08-10 07:46:19 -05001#!/bin/bash -xe
2#
3# Build the required docker image to run QEMU and Robot test cases
Lei YUba111ab2020-05-12 19:57:56 +08004
5# Script Variables:
6# UBUNTU_MIRROR: <optional, the URL of a mirror of Ubuntu to override the
7# default ones in /etc/apt/sources.list>
8# default is empty, and no mirror is used.
Andrew Geissler0205e8d2016-08-10 07:46:19 -05009#
10# Parameters:
11# parm1: <optional, the name of the docker image to generate>
12# default is openbmc/ubuntu-robot-qemu
Andrew Geissler8b8333b2018-05-29 13:51:58 -050013# param2: <optional, the distro to build a docker image against>
Andrew Geisslercd1b0ac2019-05-30 11:18:45 -050014# default is ubuntu:bionic
Andrew Geissler0205e8d2016-08-10 07:46:19 -050015
16set -uo pipefail
17
Lei YUd3748742020-05-12 19:34:26 +080018http_proxy=${http_proxy:-}
19
Andrew Geissler0205e8d2016-08-10 07:46:19 -050020DOCKER_IMG_NAME=${1:-"openbmc/ubuntu-robot-qemu"}
Andrew Geisslercd1b0ac2019-05-30 11:18:45 -050021DISTRO=${2:-"ubuntu:bionic"}
Lei YUba111ab2020-05-12 19:57:56 +080022UBUNTU_MIRROR=${UBUNTU_MIRROR:-""}
Andrew Geissler0205e8d2016-08-10 07:46:19 -050023
24# Determine our architecture, ppc64le or the other one
25if [ $(uname -m) == "ppc64le" ]; then
26 DOCKER_BASE="ppc64le/"
27else
28 DOCKER_BASE=""
29fi
30
Lei YUba111ab2020-05-12 19:57:56 +080031MIRROR=""
32if [[ -n "${UBUNTU_MIRROR}" ]]; then
33 MIRROR="RUN echo \"deb ${UBUNTU_MIRROR} \$(. /etc/os-release && echo \$VERSION_CODENAME) main restricted universe multiverse\" > /etc/apt/sources.list && \
34 echo \"deb ${UBUNTU_MIRROR} \$(. /etc/os-release && echo \$VERSION_CODENAME)-updates main restricted universe multiverse\" >> /etc/apt/sources.list && \
35 echo \"deb ${UBUNTU_MIRROR} \$(. /etc/os-release && echo \$VERSION_CODENAME)-security main restricted universe multiverse\" >> /etc/apt/sources.list && \
36 echo \"deb ${UBUNTU_MIRROR} \$(. /etc/os-release && echo \$VERSION_CODENAME)-proposed main restricted universe multiverse\" >> /etc/apt/sources.list && \
37 echo \"deb ${UBUNTU_MIRROR} \$(. /etc/os-release && echo \$VERSION_CODENAME)-backports main restricted universe multiverse\" >> /etc/apt/sources.list"
38fi
39
Andrew Geissler0205e8d2016-08-10 07:46:19 -050040################################# docker img # #################################
41# Create docker image that can run QEMU and Robot Tests
42Dockerfile=$(cat << EOF
Andrew Geissler8b8333b2018-05-29 13:51:58 -050043FROM ${DOCKER_BASE}${DISTRO}
Andrew Geissler0205e8d2016-08-10 07:46:19 -050044
Lei YUba111ab2020-05-12 19:57:56 +080045${MIRROR}
46
Andrew Geissler0205e8d2016-08-10 07:46:19 -050047ENV DEBIAN_FRONTEND noninteractive
48
49RUN apt-get update && apt-get install -yy \
50 debianutils \
51 gawk \
52 git \
53 python \
54 python-dev \
55 python-setuptools \
Saqib Khan362ca852017-03-21 10:48:46 -050056 python3 \
57 python3-dev \
58 python3-setuptools \
Andrew Geissler0205e8d2016-08-10 07:46:19 -050059 socat \
60 texinfo \
61 wget \
62 gcc \
63 libffi-dev \
64 libssl-dev \
65 xterm \
66 mwm \
67 ssh \
68 vim \
69 iputils-ping \
70 sudo \
71 cpio \
72 unzip \
73 diffstat \
74 expect \
Rahul Maheshwari6b9bb1e2017-03-13 06:56:12 -050075 curl \
Andrew Geissler7a88f292018-01-04 15:16:02 -060076 build-essential \
77 libpixman-1-0 \
Michael Walshf1e83762018-03-28 15:51:43 -050078 libglib2.0-0 \
Andrew Jeffery6ba68142018-04-05 13:30:52 +093079 sshpass \
80 libasound2 \
81 libfdt1 \
Rahul Maheshwari7285ddb2018-09-20 00:01:40 -050082 libpcre3 \
George Keishingb76c0b62019-02-25 13:16:52 -060083 openssl \
84 libxml2-dev \
George Keishing26dd8e12019-02-26 12:31:11 -060085 libxslt-dev \
Andrew Geisslercd1b0ac2019-05-30 11:18:45 -050086 python3-pip \
Anusha Dathatri39b62802019-12-18 04:01:45 -060087 ipmitool \
88 xvfb
89
90RUN apt-get update -qqy \
91 && apt-get -qqy --no-install-recommends install firefox \
92 && wget --no-verbose -O /tmp/firefox.tar.bz2 https://download-installer.cdn.mozilla.net/pub/firefox/releases/72.0/linux-x86_64/en-US/firefox-72.0.tar.bz2 \
93 && apt-get -y purge firefox \
94 && tar -C /opt -xjf /tmp/firefox.tar.bz2 \
95 && mv /opt/firefox /opt/firefox-72.0 \
96 && ln -fs /opt/firefox-72.0/firefox /usr/bin/firefox
Andrew Geissler0205e8d2016-08-10 07:46:19 -050097
Andrew Geisslercd1b0ac2019-05-30 11:18:45 -050098RUN pip3 install \
Andrew Geissler0205e8d2016-08-10 07:46:19 -050099 tox \
Andrew Geisslercd1b0ac2019-05-30 11:18:45 -0500100 requests \
Michael Sheposa4d6d3d2019-08-15 17:11:56 -0500101 retrying \
Matthew Barth04881eb2019-09-30 13:28:18 -0500102 websocket-client \
Alanny Lopez8594e432017-05-17 15:42:59 -0500103 json2yaml \
Andrew Geissler0205e8d2016-08-10 07:46:19 -0500104 robotframework \
105 robotframework-requests \
106 robotframework-sshlibrary \
Sunil M55d0d752018-03-22 07:04:17 -0500107 robotframework-scplibrary \
George Keishing0e5dd8a2018-12-02 23:17:59 -0600108 pysnmp \
Andrew Geisslercd1b0ac2019-05-30 11:18:45 -0500109 redfish \
George Keishing26dd8e12019-02-26 12:31:11 -0600110 beautifulsoup4 --upgrade \
George Keishing882254f2019-03-05 13:55:29 -0600111 lxml \
George Keishing428553d2019-04-02 10:04:11 -0500112 jsonschema \
George Keishingae29c892019-10-04 10:49:03 -0500113 redfishtool \
Anusha Dathatri39b62802019-12-18 04:01:45 -0600114 redfish_utilities \
115 robotframework-httplibrary \
116 robotframework-seleniumlibrary \
117 robotframework-xvfb \
118 robotframework-angularjs \
119 scp \
120 selenium==3.141.0 \
121 urllib3 \
122 xvfbwrapper
123
124RUN wget https://github.com/mozilla/geckodriver/releases/download/v0.26.0/geckodriver-v0.26.0-linux64.tar.gz \
125 && tar xvzf geckodriver-*.tar.gz \
126 && mv geckodriver /usr/local/bin \
127 && chmod a+x /usr/local/bin/geckodriver
Andrew Geissler0205e8d2016-08-10 07:46:19 -0500128
Andrew Geissler0205e8d2016-08-10 07:46:19 -0500129RUN grep -q ${GROUPS} /etc/group || groupadd -g ${GROUPS} ${USER}
130RUN grep -q ${UID} /etc/passwd || useradd -d ${HOME} -m -u ${UID} -g ${GROUPS} \
131 ${USER}
132USER ${USER}
133ENV HOME ${HOME}
134RUN /bin/bash
135EOF
136)
137
138################################# docker img # #################################
139
Lei YUd3748742020-05-12 19:34:26 +0800140PROXY_ARGS=""
141if [[ -n "${http_proxy}" ]]; then
142 PROXY_ARGS="--build-arg http_proxy=${http_proxy} --build-arg https_proxy=${http_proxy}"
143fi
144
Andrew Geissler0205e8d2016-08-10 07:46:19 -0500145# Build above image
Lei YUd3748742020-05-12 19:34:26 +0800146docker build ${PROXY_ARGS} -t ${DOCKER_IMG_NAME} - <<< "${Dockerfile}"