Andrew Geissler | 0205e8d | 2016-08-10 07:46:19 -0500 | [diff] [blame] | 1 | #!/bin/bash -xe |
| 2 | # |
| 3 | # Build the required docker image to run QEMU and Robot test cases |
Lei YU | ba111ab | 2020-05-12 19:57:56 +0800 | [diff] [blame] | 4 | |
| 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 YU | 51b6aec | 2020-05-13 11:32:03 +0800 | [diff] [blame] | 9 | # PIP_MIRROR: <optional, the URL of a PIP mirror> |
| 10 | # default is empty, and no mirror is used. |
Andrew Geissler | 0205e8d | 2016-08-10 07:46:19 -0500 | [diff] [blame] | 11 | # |
| 12 | # Parameters: |
| 13 | # parm1: <optional, the name of the docker image to generate> |
| 14 | # default is openbmc/ubuntu-robot-qemu |
Andrew Geissler | 8b8333b | 2018-05-29 13:51:58 -0500 | [diff] [blame] | 15 | # param2: <optional, the distro to build a docker image against> |
Andrew Geissler | 0205e8d | 2016-08-10 07:46:19 -0500 | [diff] [blame] | 16 | |
| 17 | set -uo pipefail |
| 18 | |
Lei YU | d374874 | 2020-05-12 19:34:26 +0800 | [diff] [blame] | 19 | http_proxy=${http_proxy:-} |
| 20 | |
Andrew Geissler | 0205e8d | 2016-08-10 07:46:19 -0500 | [diff] [blame] | 21 | DOCKER_IMG_NAME=${1:-"openbmc/ubuntu-robot-qemu"} |
Patrick Williams | 20b9906 | 2021-02-18 06:59:44 -0600 | [diff] [blame] | 22 | DISTRO=${2:-"ubuntu:focal"} |
Lei YU | ba111ab | 2020-05-12 19:57:56 +0800 | [diff] [blame] | 23 | UBUNTU_MIRROR=${UBUNTU_MIRROR:-""} |
Lei YU | 51b6aec | 2020-05-13 11:32:03 +0800 | [diff] [blame] | 24 | PIP_MIRROR=${PIP_MIRROR:-""} |
Andrew Geissler | 0205e8d | 2016-08-10 07:46:19 -0500 | [diff] [blame] | 25 | |
| 26 | # Determine our architecture, ppc64le or the other one |
Patrick Williams | 384d741 | 2020-11-06 16:15:41 -0600 | [diff] [blame] | 27 | if [ "$(uname -m)" == "ppc64le" ]; then |
Andrew Geissler | 0205e8d | 2016-08-10 07:46:19 -0500 | [diff] [blame] | 28 | DOCKER_BASE="ppc64le/" |
| 29 | else |
| 30 | DOCKER_BASE="" |
| 31 | fi |
| 32 | |
Lei YU | ba111ab | 2020-05-12 19:57:56 +0800 | [diff] [blame] | 33 | MIRROR="" |
| 34 | if [[ -n "${UBUNTU_MIRROR}" ]]; then |
| 35 | MIRROR="RUN echo \"deb ${UBUNTU_MIRROR} \$(. /etc/os-release && echo \$VERSION_CODENAME) main restricted universe multiverse\" > /etc/apt/sources.list && \ |
| 36 | echo \"deb ${UBUNTU_MIRROR} \$(. /etc/os-release && echo \$VERSION_CODENAME)-updates main restricted universe multiverse\" >> /etc/apt/sources.list && \ |
| 37 | echo \"deb ${UBUNTU_MIRROR} \$(. /etc/os-release && echo \$VERSION_CODENAME)-security main restricted universe multiverse\" >> /etc/apt/sources.list && \ |
| 38 | echo \"deb ${UBUNTU_MIRROR} \$(. /etc/os-release && echo \$VERSION_CODENAME)-proposed main restricted universe multiverse\" >> /etc/apt/sources.list && \ |
| 39 | echo \"deb ${UBUNTU_MIRROR} \$(. /etc/os-release && echo \$VERSION_CODENAME)-backports main restricted universe multiverse\" >> /etc/apt/sources.list" |
| 40 | fi |
| 41 | |
Lei YU | 51b6aec | 2020-05-13 11:32:03 +0800 | [diff] [blame] | 42 | PIP_MIRROR_CMD="" |
| 43 | if [[ -n "${PIP_MIRROR}" ]]; then |
Patrick Williams | 384d741 | 2020-11-06 16:15:41 -0600 | [diff] [blame] | 44 | PIP_HOSTNAME=$(echo "${PIP_MIRROR}" | awk -F[/:] '{print $4}') |
Lei YU | 51b6aec | 2020-05-13 11:32:03 +0800 | [diff] [blame] | 45 | PIP_MIRROR_CMD="RUN mkdir -p \${HOME}/.pip && \ |
| 46 | echo \"[global]\" > \${HOME}/.pip/pip.conf && \ |
| 47 | echo \"index-url=${PIP_MIRROR}\" >> \${HOME}/.pip/pip.conf &&\ |
| 48 | echo \"[install]\" >> \${HOME}/.pip/pip.conf &&\ |
| 49 | echo \"trusted-host=${PIP_HOSTNAME}\" >> \${HOME}/.pip/pip.conf" |
| 50 | fi |
| 51 | |
Andrew Geissler | 0205e8d | 2016-08-10 07:46:19 -0500 | [diff] [blame] | 52 | ################################# docker img # ################################# |
| 53 | # Create docker image that can run QEMU and Robot Tests |
| 54 | Dockerfile=$(cat << EOF |
Andrew Geissler | 8b8333b | 2018-05-29 13:51:58 -0500 | [diff] [blame] | 55 | FROM ${DOCKER_BASE}${DISTRO} |
Andrew Geissler | 0205e8d | 2016-08-10 07:46:19 -0500 | [diff] [blame] | 56 | |
Lei YU | ba111ab | 2020-05-12 19:57:56 +0800 | [diff] [blame] | 57 | ${MIRROR} |
| 58 | |
Lei YU | 51b6aec | 2020-05-13 11:32:03 +0800 | [diff] [blame] | 59 | ARG DEBIAN_FRONTEND=noninteractive |
Andrew Geissler | 0205e8d | 2016-08-10 07:46:19 -0500 | [diff] [blame] | 60 | |
| 61 | RUN apt-get update && apt-get install -yy \ |
| 62 | debianutils \ |
| 63 | gawk \ |
| 64 | git \ |
| 65 | python \ |
| 66 | python-dev \ |
| 67 | python-setuptools \ |
Saqib Khan | 362ca85 | 2017-03-21 10:48:46 -0500 | [diff] [blame] | 68 | python3 \ |
| 69 | python3-dev \ |
| 70 | python3-setuptools \ |
Andrew Geissler | 0205e8d | 2016-08-10 07:46:19 -0500 | [diff] [blame] | 71 | socat \ |
| 72 | texinfo \ |
| 73 | wget \ |
| 74 | gcc \ |
| 75 | libffi-dev \ |
| 76 | libssl-dev \ |
| 77 | xterm \ |
| 78 | mwm \ |
| 79 | ssh \ |
| 80 | vim \ |
| 81 | iputils-ping \ |
| 82 | sudo \ |
| 83 | cpio \ |
| 84 | unzip \ |
| 85 | diffstat \ |
| 86 | expect \ |
Rahul Maheshwari | 6b9bb1e | 2017-03-13 06:56:12 -0500 | [diff] [blame] | 87 | curl \ |
Andrew Geissler | 7a88f29 | 2018-01-04 15:16:02 -0600 | [diff] [blame] | 88 | build-essential \ |
| 89 | libpixman-1-0 \ |
Michael Walsh | f1e8376 | 2018-03-28 15:51:43 -0500 | [diff] [blame] | 90 | libglib2.0-0 \ |
Andrew Jeffery | 6ba6814 | 2018-04-05 13:30:52 +0930 | [diff] [blame] | 91 | sshpass \ |
| 92 | libasound2 \ |
| 93 | libfdt1 \ |
Rahul Maheshwari | 7285ddb | 2018-09-20 00:01:40 -0500 | [diff] [blame] | 94 | libpcre3 \ |
George Keishing | b76c0b6 | 2019-02-25 13:16:52 -0600 | [diff] [blame] | 95 | openssl \ |
| 96 | libxml2-dev \ |
George Keishing | 26dd8e1 | 2019-02-26 12:31:11 -0600 | [diff] [blame] | 97 | libxslt-dev \ |
Andrew Geissler | cd1b0ac | 2019-05-30 11:18:45 -0500 | [diff] [blame] | 98 | python3-pip \ |
Anusha Dathatri | 39b6280 | 2019-12-18 04:01:45 -0600 | [diff] [blame] | 99 | ipmitool \ |
Andrew Geissler | 6ddfc29 | 2021-02-23 18:46:17 -0600 | [diff] [blame] | 100 | xvfb \ |
| 101 | rustc |
Anusha Dathatri | 39b6280 | 2019-12-18 04:01:45 -0600 | [diff] [blame] | 102 | |
| 103 | RUN 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 Geissler | 0205e8d | 2016-08-10 07:46:19 -0500 | [diff] [blame] | 110 | |
Lei YU | 51b6aec | 2020-05-13 11:32:03 +0800 | [diff] [blame] | 111 | ENV HOME ${HOME} |
| 112 | |
| 113 | ${PIP_MIRROR_CMD} |
| 114 | |
Andrew Geissler | cd1b0ac | 2019-05-30 11:18:45 -0500 | [diff] [blame] | 115 | RUN pip3 install \ |
Andrew Geissler | 0205e8d | 2016-08-10 07:46:19 -0500 | [diff] [blame] | 116 | tox \ |
Andrew Geissler | cd1b0ac | 2019-05-30 11:18:45 -0500 | [diff] [blame] | 117 | requests \ |
Michael Shepos | a4d6d3d | 2019-08-15 17:11:56 -0500 | [diff] [blame] | 118 | retrying \ |
Matthew Barth | 04881eb | 2019-09-30 13:28:18 -0500 | [diff] [blame] | 119 | websocket-client \ |
Alanny Lopez | 8594e43 | 2017-05-17 15:42:59 -0500 | [diff] [blame] | 120 | json2yaml \ |
Andrew Geissler | 0205e8d | 2016-08-10 07:46:19 -0500 | [diff] [blame] | 121 | robotframework \ |
Andrew Geissler | 1e99b50 | 2021-02-24 10:44:11 -0600 | [diff] [blame] | 122 | robotframework-requests==0.7.0 \ |
Andrew Geissler | 0205e8d | 2016-08-10 07:46:19 -0500 | [diff] [blame] | 123 | robotframework-sshlibrary \ |
Sunil M | 55d0d75 | 2018-03-22 07:04:17 -0500 | [diff] [blame] | 124 | robotframework-scplibrary \ |
George Keishing | 0e5dd8a | 2018-12-02 23:17:59 -0600 | [diff] [blame] | 125 | pysnmp \ |
Andrew Geissler | cd1b0ac | 2019-05-30 11:18:45 -0500 | [diff] [blame] | 126 | redfish \ |
George Keishing | 26dd8e1 | 2019-02-26 12:31:11 -0600 | [diff] [blame] | 127 | beautifulsoup4 --upgrade \ |
George Keishing | 882254f | 2019-03-05 13:55:29 -0600 | [diff] [blame] | 128 | lxml \ |
George Keishing | 428553d | 2019-04-02 10:04:11 -0500 | [diff] [blame] | 129 | jsonschema \ |
George Keishing | ae29c89 | 2019-10-04 10:49:03 -0500 | [diff] [blame] | 130 | redfishtool \ |
Anusha Dathatri | 39b6280 | 2019-12-18 04:01:45 -0600 | [diff] [blame] | 131 | redfish_utilities \ |
| 132 | robotframework-httplibrary \ |
| 133 | robotframework-seleniumlibrary \ |
| 134 | robotframework-xvfb \ |
| 135 | robotframework-angularjs \ |
| 136 | scp \ |
| 137 | selenium==3.141.0 \ |
| 138 | urllib3 \ |
George Keishing | 092ec34 | 2021-08-04 01:01:51 -0500 | [diff] [blame] | 139 | click \ |
Anusha Dathatri | 39b6280 | 2019-12-18 04:01:45 -0600 | [diff] [blame] | 140 | xvfbwrapper |
| 141 | |
Rahul Maheshwari | 733acb2 | 2021-02-01 19:43:07 -0600 | [diff] [blame] | 142 | RUN wget https://github.com/mozilla/geckodriver/releases/download/v0.29.0/geckodriver-v0.29.0-linux64.tar.gz \ |
Anusha Dathatri | 39b6280 | 2019-12-18 04:01:45 -0600 | [diff] [blame] | 143 | && tar xvzf geckodriver-*.tar.gz \ |
| 144 | && mv geckodriver /usr/local/bin \ |
| 145 | && chmod a+x /usr/local/bin/geckodriver |
Andrew Geissler | 0205e8d | 2016-08-10 07:46:19 -0500 | [diff] [blame] | 146 | |
Patrick Williams | 384d741 | 2020-11-06 16:15:41 -0600 | [diff] [blame] | 147 | RUN grep -q ${GROUPS[0]} /etc/group || groupadd -g ${GROUPS[0]} ${USER} |
| 148 | RUN grep -q ${UID} /etc/passwd || useradd -d ${HOME} -m -u ${UID} -g ${GROUPS[0]} \ |
Andrew Geissler | 0205e8d | 2016-08-10 07:46:19 -0500 | [diff] [blame] | 149 | ${USER} |
| 150 | USER ${USER} |
Andrew Geissler | 0205e8d | 2016-08-10 07:46:19 -0500 | [diff] [blame] | 151 | RUN /bin/bash |
| 152 | EOF |
| 153 | ) |
| 154 | |
| 155 | ################################# docker img # ################################# |
| 156 | |
Lei YU | d374874 | 2020-05-12 19:34:26 +0800 | [diff] [blame] | 157 | PROXY_ARGS="" |
| 158 | if [[ -n "${http_proxy}" ]]; then |
| 159 | PROXY_ARGS="--build-arg http_proxy=${http_proxy} --build-arg https_proxy=${http_proxy}" |
| 160 | fi |
| 161 | |
Andrew Geissler | 0205e8d | 2016-08-10 07:46:19 -0500 | [diff] [blame] | 162 | # Build above image |
Patrick Williams | 384d741 | 2020-11-06 16:15:41 -0600 | [diff] [blame] | 163 | # shellcheck disable=SC2086 # PROXY_ARGS is intentionally word-split. |
| 164 | docker build ${PROXY_ARGS} -t "${DOCKER_IMG_NAME}" - <<< "${Dockerfile}" |