blob: c8e402a2c14f21d4686737f14da498908f9ef0b2 [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 Geisslerb80ea072024-10-07 15:43:34 -040011# DOCKER_REG: <optional, the URL of a docker registry to utilize
12# instead of the default docker hub
13# (ex. public.ecr.aws/ubuntu)
Andrew Geissler0205e8d2016-08-10 07:46:19 -050014#
15# Parameters:
16# parm1: <optional, the name of the docker image to generate>
17# default is openbmc/ubuntu-robot-qemu
Andrew Geissler8b8333b2018-05-29 13:51:58 -050018# param2: <optional, the distro to build a docker image against>
Andrew Geissler0205e8d2016-08-10 07:46:19 -050019
20set -uo pipefail
21
Lei YUd3748742020-05-12 19:34:26 +080022http_proxy=${http_proxy:-}
23
Andrew Geissler0205e8d2016-08-10 07:46:19 -050024DOCKER_IMG_NAME=${1:-"openbmc/ubuntu-robot-qemu"}
Nan Zhou86ae1352022-06-27 22:30:55 +000025DISTRO=${2:-"ubuntu:jammy"}
Lei YUba111ab2020-05-12 19:57:56 +080026UBUNTU_MIRROR=${UBUNTU_MIRROR:-""}
Lei YU51b6aec2020-05-13 11:32:03 +080027PIP_MIRROR=${PIP_MIRROR:-""}
Andrew Geisslerb80ea072024-10-07 15:43:34 -040028docker_reg=${DOCKER_REG:-"docker.io"}
Andrew Geissler0205e8d2016-08-10 07:46:19 -050029
Lei YUba111ab2020-05-12 19:57:56 +080030MIRROR=""
31if [[ -n "${UBUNTU_MIRROR}" ]]; then
32 MIRROR="RUN echo \"deb ${UBUNTU_MIRROR} \$(. /etc/os-release && echo \$VERSION_CODENAME) main restricted universe multiverse\" > /etc/apt/sources.list && \
33 echo \"deb ${UBUNTU_MIRROR} \$(. /etc/os-release && echo \$VERSION_CODENAME)-updates main restricted universe multiverse\" >> /etc/apt/sources.list && \
34 echo \"deb ${UBUNTU_MIRROR} \$(. /etc/os-release && echo \$VERSION_CODENAME)-security main restricted universe multiverse\" >> /etc/apt/sources.list && \
35 echo \"deb ${UBUNTU_MIRROR} \$(. /etc/os-release && echo \$VERSION_CODENAME)-proposed main restricted universe multiverse\" >> /etc/apt/sources.list && \
36 echo \"deb ${UBUNTU_MIRROR} \$(. /etc/os-release && echo \$VERSION_CODENAME)-backports main restricted universe multiverse\" >> /etc/apt/sources.list"
37fi
38
Lei YU51b6aec2020-05-13 11:32:03 +080039PIP_MIRROR_CMD=""
40if [[ -n "${PIP_MIRROR}" ]]; then
Patrick Williams384d7412020-11-06 16:15:41 -060041 PIP_HOSTNAME=$(echo "${PIP_MIRROR}" | awk -F[/:] '{print $4}')
Lei YU51b6aec2020-05-13 11:32:03 +080042 PIP_MIRROR_CMD="RUN mkdir -p \${HOME}/.pip && \
43 echo \"[global]\" > \${HOME}/.pip/pip.conf && \
44 echo \"index-url=${PIP_MIRROR}\" >> \${HOME}/.pip/pip.conf &&\
45 echo \"[install]\" >> \${HOME}/.pip/pip.conf &&\
46 echo \"trusted-host=${PIP_HOSTNAME}\" >> \${HOME}/.pip/pip.conf"
47fi
48
Andrew Geissler0205e8d2016-08-10 07:46:19 -050049################################# docker img # #################################
50# Create docker image that can run QEMU and Robot Tests
51Dockerfile=$(cat << EOF
Andrew Geisslerb80ea072024-10-07 15:43:34 -040052FROM ${docker_reg}/${DISTRO}
Andrew Geissler0205e8d2016-08-10 07:46:19 -050053
Lei YUba111ab2020-05-12 19:57:56 +080054${MIRROR}
55
Lei YU51b6aec2020-05-13 11:32:03 +080056ARG DEBIAN_FRONTEND=noninteractive
Andrew Geissler0205e8d2016-08-10 07:46:19 -050057
58RUN apt-get update && apt-get install -yy \
59 debianutils \
60 gawk \
61 git \
Nan Zhou86ae1352022-06-27 22:30:55 +000062 python2 \
63 python2-dev \
Andrew Geissler0205e8d2016-08-10 07:46:19 -050064 python-setuptools \
Saqib Khan362ca852017-03-21 10:48:46 -050065 python3 \
66 python3-dev \
67 python3-setuptools \
Andrew Geissler0205e8d2016-08-10 07:46:19 -050068 socat \
69 texinfo \
70 wget \
71 gcc \
72 libffi-dev \
73 libssl-dev \
74 xterm \
75 mwm \
76 ssh \
77 vim \
78 iputils-ping \
79 sudo \
80 cpio \
81 unzip \
82 diffstat \
83 expect \
Rahul Maheshwari6b9bb1e2017-03-13 06:56:12 -050084 curl \
Andrew Geissler7a88f292018-01-04 15:16:02 -060085 build-essential \
Rahul Maheshwari3eafe342024-02-14 02:58:23 -060086 libdbus-glib-1-2 \
Andrew Geissler7a88f292018-01-04 15:16:02 -060087 libpixman-1-0 \
Michael Walshf1e83762018-03-28 15:51:43 -050088 libglib2.0-0 \
Andrew Jeffery6ba68142018-04-05 13:30:52 +093089 sshpass \
90 libasound2 \
91 libfdt1 \
Rahul Maheshwari7285ddb2018-09-20 00:01:40 -050092 libpcre3 \
Andrew Geissler851eaff2022-12-22 09:47:54 -060093 libslirp-dev \
George Keishingb76c0b62019-02-25 13:16:52 -060094 openssl \
95 libxml2-dev \
George Keishing26dd8e12019-02-26 12:31:11 -060096 libxslt-dev \
Andrew Geisslercd1b0ac2019-05-30 11:18:45 -050097 python3-pip \
Anusha Dathatri39b62802019-12-18 04:01:45 -060098 ipmitool \
Andrew Geissler6ddfc292021-02-23 18:46:17 -060099 xvfb \
100 rustc
Anusha Dathatri39b62802019-12-18 04:01:45 -0600101
102RUN apt-get update -qqy \
103 && apt-get -qqy --no-install-recommends install firefox \
Rahul Maheshwari744b3bb2023-09-20 10:12:47 -0500104 && 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 Dathatri39b62802019-12-18 04:01:45 -0600105 && apt-get -y purge firefox \
106 && tar -C /opt -xjf /tmp/firefox.tar.bz2 \
Rahul Maheshwari744b3bb2023-09-20 10:12:47 -0500107 && mv /opt/firefox /opt/firefox-112.0.2 \
108 && ln -fs /opt/firefox-112.0.2/firefox /usr/bin/firefox
Andrew Geissler0205e8d2016-08-10 07:46:19 -0500109
Lei YU51b6aec2020-05-13 11:32:03 +0800110ENV HOME ${HOME}
111
112${PIP_MIRROR_CMD}
113
Andrew Geisslercd1b0ac2019-05-30 11:18:45 -0500114RUN pip3 install \
Andrew Geissler0205e8d2016-08-10 07:46:19 -0500115 tox \
Andrew Geisslercd1b0ac2019-05-30 11:18:45 -0500116 requests \
Michael Sheposa4d6d3d2019-08-15 17:11:56 -0500117 retrying \
Matthew Barth04881eb2019-09-30 13:28:18 -0500118 websocket-client \
Alanny Lopez8594e432017-05-17 15:42:59 -0500119 json2yaml \
George Keishing22de2382024-09-09 20:27:09 +0530120 robotframework==7.0.1 \
George Keishing09dcd892022-08-02 08:12:15 -0500121 robotframework-requests \
122 robotframework-jsonlibrary \
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 \
Jian Zhang8b362562022-09-22 21:21:15 +0800126 redfish>=3.1.7 \
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 \
Rahul Maheshwari744b3bb2023-09-20 10:12:47 -0500133 robotframework-seleniumlibrary==6.0.0 \
134 robotframework-xvfb==1.2.2 \
Anusha Dathatri39b62802019-12-18 04:01:45 -0600135 robotframework-angularjs \
136 scp \
Rahul Maheshwari744b3bb2023-09-20 10:12:47 -0500137 selenium==4.8.2 \
Anusha Dathatri39b62802019-12-18 04:01:45 -0600138 urllib3 \
George Keishing092ec342021-08-04 01:01:51 -0500139 click \
Rahul Maheshwari744b3bb2023-09-20 10:12:47 -0500140 xvfbwrapper==0.2.9
Anusha Dathatri39b62802019-12-18 04:01:45 -0600141
Rahul Maheshwari744b3bb2023-09-20 10:12:47 -0500142RUN wget https://github.com/mozilla/geckodriver/releases/download/v0.32.2/geckodriver-v0.32.2-linux64.tar.gz \
Anusha Dathatri39b62802019-12-18 04:01:45 -0600143 && tar xvzf geckodriver-*.tar.gz \
144 && mv geckodriver /usr/local/bin \
145 && chmod a+x /usr/local/bin/geckodriver
Andrew Geissler0205e8d2016-08-10 07:46:19 -0500146
Patrick Williams384d7412020-11-06 16:15:41 -0600147RUN grep -q ${GROUPS[0]} /etc/group || groupadd -g ${GROUPS[0]} ${USER}
Nan Zhouc2796fe2022-01-28 21:28:00 +0000148RUN grep -q ${UID} /etc/passwd || useradd -d ${HOME} -l -m -u ${UID} -g ${GROUPS[0]} \
Andrew Geissler0205e8d2016-08-10 07:46:19 -0500149 ${USER}
150USER ${USER}
Andrew Geissler0205e8d2016-08-10 07:46:19 -0500151RUN /bin/bash
152EOF
153)
154
155################################# docker img # #################################
156
Lei YUd3748742020-05-12 19:34:26 +0800157PROXY_ARGS=""
158if [[ -n "${http_proxy}" ]]; then
Patrick Williams476a7e92022-12-06 09:52:53 -0600159 PROXY_ARGS="--build-arg http_proxy=${http_proxy} --build-arg https_proxy=${http_proxy}"
Lei YUd3748742020-05-12 19:34:26 +0800160fi
161
Andrew Geissler0205e8d2016-08-10 07:46:19 -0500162# Build above image
Patrick Williams384d7412020-11-06 16:15:41 -0600163# shellcheck disable=SC2086 # PROXY_ARGS is intentionally word-split.
164docker build ${PROXY_ARGS} -t "${DOCKER_IMG_NAME}" - <<< "${Dockerfile}"