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