blob: f00b9966bdcb2c11d283cdda090420d335948922 [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.
Lei YU51b6aec2020-05-13 11:32:03 +08009# PIP_MIRROR: <optional, the URL of a PIP mirror>
10# default is empty, and no mirror is used.
Andrew Geissler0205e8d2016-08-10 07:46:19 -050011#
12# Parameters:
13# parm1: <optional, the name of the docker image to generate>
14# default is openbmc/ubuntu-robot-qemu
Andrew Geissler8b8333b2018-05-29 13:51:58 -050015# param2: <optional, the distro to build a docker image against>
Patrick Williams20b99062021-02-18 06:59:44 -060016# default is ubuntu:focal
Andrew Geissler0205e8d2016-08-10 07:46:19 -050017
18set -uo pipefail
19
Lei YUd3748742020-05-12 19:34:26 +080020http_proxy=${http_proxy:-}
21
Andrew Geissler0205e8d2016-08-10 07:46:19 -050022DOCKER_IMG_NAME=${1:-"openbmc/ubuntu-robot-qemu"}
Patrick Williams20b99062021-02-18 06:59:44 -060023DISTRO=${2:-"ubuntu:focal"}
Lei YUba111ab2020-05-12 19:57:56 +080024UBUNTU_MIRROR=${UBUNTU_MIRROR:-""}
Lei YU51b6aec2020-05-13 11:32:03 +080025PIP_MIRROR=${PIP_MIRROR:-""}
Andrew Geissler0205e8d2016-08-10 07:46:19 -050026
27# Determine our architecture, ppc64le or the other one
Patrick Williams384d7412020-11-06 16:15:41 -060028if [ "$(uname -m)" == "ppc64le" ]; then
Andrew Geissler0205e8d2016-08-10 07:46:19 -050029 DOCKER_BASE="ppc64le/"
30else
31 DOCKER_BASE=""
32fi
33
Lei YUba111ab2020-05-12 19:57:56 +080034MIRROR=""
35if [[ -n "${UBUNTU_MIRROR}" ]]; then
36 MIRROR="RUN echo \"deb ${UBUNTU_MIRROR} \$(. /etc/os-release && echo \$VERSION_CODENAME) main restricted universe multiverse\" > /etc/apt/sources.list && \
37 echo \"deb ${UBUNTU_MIRROR} \$(. /etc/os-release && echo \$VERSION_CODENAME)-updates main restricted universe multiverse\" >> /etc/apt/sources.list && \
38 echo \"deb ${UBUNTU_MIRROR} \$(. /etc/os-release && echo \$VERSION_CODENAME)-security main restricted universe multiverse\" >> /etc/apt/sources.list && \
39 echo \"deb ${UBUNTU_MIRROR} \$(. /etc/os-release && echo \$VERSION_CODENAME)-proposed main restricted universe multiverse\" >> /etc/apt/sources.list && \
40 echo \"deb ${UBUNTU_MIRROR} \$(. /etc/os-release && echo \$VERSION_CODENAME)-backports main restricted universe multiverse\" >> /etc/apt/sources.list"
41fi
42
Lei YU51b6aec2020-05-13 11:32:03 +080043PIP_MIRROR_CMD=""
44if [[ -n "${PIP_MIRROR}" ]]; then
Patrick Williams384d7412020-11-06 16:15:41 -060045 PIP_HOSTNAME=$(echo "${PIP_MIRROR}" | awk -F[/:] '{print $4}')
Lei YU51b6aec2020-05-13 11:32:03 +080046 PIP_MIRROR_CMD="RUN mkdir -p \${HOME}/.pip && \
47 echo \"[global]\" > \${HOME}/.pip/pip.conf && \
48 echo \"index-url=${PIP_MIRROR}\" >> \${HOME}/.pip/pip.conf &&\
49 echo \"[install]\" >> \${HOME}/.pip/pip.conf &&\
50 echo \"trusted-host=${PIP_HOSTNAME}\" >> \${HOME}/.pip/pip.conf"
51fi
52
Andrew Geissler0205e8d2016-08-10 07:46:19 -050053################################# docker img # #################################
54# Create docker image that can run QEMU and Robot Tests
55Dockerfile=$(cat << EOF
Andrew Geissler8b8333b2018-05-29 13:51:58 -050056FROM ${DOCKER_BASE}${DISTRO}
Andrew Geissler0205e8d2016-08-10 07:46:19 -050057
Lei YUba111ab2020-05-12 19:57:56 +080058${MIRROR}
59
Lei YU51b6aec2020-05-13 11:32:03 +080060ARG DEBIAN_FRONTEND=noninteractive
Andrew Geissler0205e8d2016-08-10 07:46:19 -050061
62RUN apt-get update && apt-get install -yy \
63 debianutils \
64 gawk \
65 git \
66 python \
67 python-dev \
68 python-setuptools \
Saqib Khan362ca852017-03-21 10:48:46 -050069 python3 \
70 python3-dev \
71 python3-setuptools \
Andrew Geissler0205e8d2016-08-10 07:46:19 -050072 socat \
73 texinfo \
74 wget \
75 gcc \
76 libffi-dev \
77 libssl-dev \
78 xterm \
79 mwm \
80 ssh \
81 vim \
82 iputils-ping \
83 sudo \
84 cpio \
85 unzip \
86 diffstat \
87 expect \
Rahul Maheshwari6b9bb1e2017-03-13 06:56:12 -050088 curl \
Andrew Geissler7a88f292018-01-04 15:16:02 -060089 build-essential \
90 libpixman-1-0 \
Michael Walshf1e83762018-03-28 15:51:43 -050091 libglib2.0-0 \
Andrew Jeffery6ba68142018-04-05 13:30:52 +093092 sshpass \
93 libasound2 \
94 libfdt1 \
Rahul Maheshwari7285ddb2018-09-20 00:01:40 -050095 libpcre3 \
George Keishingb76c0b62019-02-25 13:16:52 -060096 openssl \
97 libxml2-dev \
George Keishing26dd8e12019-02-26 12:31:11 -060098 libxslt-dev \
Andrew Geisslercd1b0ac2019-05-30 11:18:45 -050099 python3-pip \
Anusha Dathatri39b62802019-12-18 04:01:45 -0600100 ipmitool \
101 xvfb
102
103RUN apt-get update -qqy \
104 && apt-get -qqy --no-install-recommends install firefox \
105 && 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 \
106 && apt-get -y purge firefox \
107 && tar -C /opt -xjf /tmp/firefox.tar.bz2 \
108 && mv /opt/firefox /opt/firefox-72.0 \
109 && ln -fs /opt/firefox-72.0/firefox /usr/bin/firefox
Andrew Geissler0205e8d2016-08-10 07:46:19 -0500110
Lei YU51b6aec2020-05-13 11:32:03 +0800111ENV HOME ${HOME}
112
113${PIP_MIRROR_CMD}
114
Andrew Geisslercd1b0ac2019-05-30 11:18:45 -0500115RUN pip3 install \
Andrew Geissler0205e8d2016-08-10 07:46:19 -0500116 tox \
Andrew Geisslercd1b0ac2019-05-30 11:18:45 -0500117 requests \
Michael Sheposa4d6d3d2019-08-15 17:11:56 -0500118 retrying \
Matthew Barth04881eb2019-09-30 13:28:18 -0500119 websocket-client \
Alanny Lopez8594e432017-05-17 15:42:59 -0500120 json2yaml \
Andrew Geissler0205e8d2016-08-10 07:46:19 -0500121 robotframework \
Andrew Geissler1e99b502021-02-24 10:44:11 -0600122 robotframework-requests==0.7.0 \
Andrew Geissler0205e8d2016-08-10 07:46:19 -0500123 robotframework-sshlibrary \
Sunil M55d0d752018-03-22 07:04:17 -0500124 robotframework-scplibrary \
George Keishing0e5dd8a2018-12-02 23:17:59 -0600125 pysnmp \
Andrew Geisslercd1b0ac2019-05-30 11:18:45 -0500126 redfish \
George Keishing26dd8e12019-02-26 12:31:11 -0600127 beautifulsoup4 --upgrade \
George Keishing882254f2019-03-05 13:55:29 -0600128 lxml \
George Keishing428553d2019-04-02 10:04:11 -0500129 jsonschema \
George Keishingae29c892019-10-04 10:49:03 -0500130 redfishtool \
Anusha Dathatri39b62802019-12-18 04:01:45 -0600131 redfish_utilities \
132 robotframework-httplibrary \
133 robotframework-seleniumlibrary \
134 robotframework-xvfb \
135 robotframework-angularjs \
136 scp \
137 selenium==3.141.0 \
138 urllib3 \
139 xvfbwrapper
140
Rahul Maheshwari733acb22021-02-01 19:43:07 -0600141RUN wget https://github.com/mozilla/geckodriver/releases/download/v0.29.0/geckodriver-v0.29.0-linux64.tar.gz \
Anusha Dathatri39b62802019-12-18 04:01:45 -0600142 && tar xvzf geckodriver-*.tar.gz \
143 && mv geckodriver /usr/local/bin \
144 && chmod a+x /usr/local/bin/geckodriver
Andrew Geissler0205e8d2016-08-10 07:46:19 -0500145
Patrick Williams384d7412020-11-06 16:15:41 -0600146RUN grep -q ${GROUPS[0]} /etc/group || groupadd -g ${GROUPS[0]} ${USER}
147RUN grep -q ${UID} /etc/passwd || useradd -d ${HOME} -m -u ${UID} -g ${GROUPS[0]} \
Andrew Geissler0205e8d2016-08-10 07:46:19 -0500148 ${USER}
149USER ${USER}
Andrew Geissler0205e8d2016-08-10 07:46:19 -0500150RUN /bin/bash
151EOF
152)
153
154################################# docker img # #################################
155
Lei YUd3748742020-05-12 19:34:26 +0800156PROXY_ARGS=""
157if [[ -n "${http_proxy}" ]]; then
158 PROXY_ARGS="--build-arg http_proxy=${http_proxy} --build-arg https_proxy=${http_proxy}"
159fi
160
Andrew Geissler0205e8d2016-08-10 07:46:19 -0500161# Build above image
Patrick Williams384d7412020-11-06 16:15:41 -0600162# shellcheck disable=SC2086 # PROXY_ARGS is intentionally word-split.
163docker build ${PROXY_ARGS} -t "${DOCKER_IMG_NAME}" - <<< "${Dockerfile}"