blob: 4517ffd01285973b30567b858d289eb52ae67df8 [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
Andrew Geisslerfb45daa2024-10-09 12:26:56 -040012# instead of our default (public.ecr.aws/ubuntu)
13# (ex. docker.io)
Andrew Geissler0205e8d2016-08-10 07:46:19 -050014# Parameters:
15# parm1: <optional, the name of the docker image to generate>
16# default is openbmc/ubuntu-robot-qemu
Andrew Geissler8b8333b2018-05-29 13:51:58 -050017# param2: <optional, the distro to build a docker image against>
Andrew Geissler0205e8d2016-08-10 07:46:19 -050018
19set -uo pipefail
20
Lei YUd3748742020-05-12 19:34:26 +080021http_proxy=${http_proxy:-}
22
Andrew Geissler0205e8d2016-08-10 07:46:19 -050023DOCKER_IMG_NAME=${1:-"openbmc/ubuntu-robot-qemu"}
Nan Zhou86ae1352022-06-27 22:30:55 +000024DISTRO=${2:-"ubuntu:jammy"}
Lei YUba111ab2020-05-12 19:57:56 +080025UBUNTU_MIRROR=${UBUNTU_MIRROR:-""}
Lei YU51b6aec2020-05-13 11:32:03 +080026PIP_MIRROR=${PIP_MIRROR:-""}
Andrew Geisslerfb45daa2024-10-09 12:26:56 -040027docker_reg=${DOCKER_REG:-"public.ecr.aws/ubuntu"}
Andrew Geissler0205e8d2016-08-10 07:46:19 -050028
Lei YUba111ab2020-05-12 19:57:56 +080029MIRROR=""
30if [[ -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"
36fi
37
Lei YU51b6aec2020-05-13 11:32:03 +080038PIP_MIRROR_CMD=""
39if [[ -n "${PIP_MIRROR}" ]]; then
Patrick Williams384d7412020-11-06 16:15:41 -060040 PIP_HOSTNAME=$(echo "${PIP_MIRROR}" | awk -F[/:] '{print $4}')
Lei YU51b6aec2020-05-13 11:32:03 +080041 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"
46fi
47
Andrew Geissler0205e8d2016-08-10 07:46:19 -050048################################# docker img # #################################
49# Create docker image that can run QEMU and Robot Tests
50Dockerfile=$(cat << EOF
Andrew Geisslerb80ea072024-10-07 15:43:34 -040051FROM ${docker_reg}/${DISTRO}
Andrew Geissler0205e8d2016-08-10 07:46:19 -050052
Lei YUba111ab2020-05-12 19:57:56 +080053${MIRROR}
54
Lei YU51b6aec2020-05-13 11:32:03 +080055ARG DEBIAN_FRONTEND=noninteractive
Andrew Geissler0205e8d2016-08-10 07:46:19 -050056
57RUN apt-get update && apt-get install -yy \
58 debianutils \
59 gawk \
60 git \
Nan Zhou86ae1352022-06-27 22:30:55 +000061 python2 \
62 python2-dev \
Andrew Geissler0205e8d2016-08-10 07:46:19 -050063 python-setuptools \
Saqib Khan362ca852017-03-21 10:48:46 -050064 python3 \
65 python3-dev \
66 python3-setuptools \
Andrew Geissler0205e8d2016-08-10 07:46:19 -050067 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 Maheshwari6b9bb1e2017-03-13 06:56:12 -050083 curl \
Andrew Geissler7a88f292018-01-04 15:16:02 -060084 build-essential \
Rahul Maheshwari3eafe342024-02-14 02:58:23 -060085 libdbus-glib-1-2 \
Andrew Geissler7a88f292018-01-04 15:16:02 -060086 libpixman-1-0 \
Michael Walshf1e83762018-03-28 15:51:43 -050087 libglib2.0-0 \
Andrew Jeffery6ba68142018-04-05 13:30:52 +093088 sshpass \
89 libasound2 \
90 libfdt1 \
Rahul Maheshwari7285ddb2018-09-20 00:01:40 -050091 libpcre3 \
Andrew Geissler851eaff2022-12-22 09:47:54 -060092 libslirp-dev \
George Keishingb76c0b62019-02-25 13:16:52 -060093 openssl \
94 libxml2-dev \
George Keishing26dd8e12019-02-26 12:31:11 -060095 libxslt-dev \
Andrew Geisslercd1b0ac2019-05-30 11:18:45 -050096 python3-pip \
Anusha Dathatri39b62802019-12-18 04:01:45 -060097 ipmitool \
Andrew Geissler6ddfc292021-02-23 18:46:17 -060098 xvfb \
99 rustc
Anusha Dathatri39b62802019-12-18 04:01:45 -0600100
101RUN apt-get update -qqy \
102 && apt-get -qqy --no-install-recommends install firefox \
Rahul Maheshwari744b3bb2023-09-20 10:12:47 -0500103 && 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 -0600104 && apt-get -y purge firefox \
105 && tar -C /opt -xjf /tmp/firefox.tar.bz2 \
Rahul Maheshwari744b3bb2023-09-20 10:12:47 -0500106 && mv /opt/firefox /opt/firefox-112.0.2 \
107 && ln -fs /opt/firefox-112.0.2/firefox /usr/bin/firefox
Andrew Geissler0205e8d2016-08-10 07:46:19 -0500108
Lei YU51b6aec2020-05-13 11:32:03 +0800109ENV HOME ${HOME}
110
111${PIP_MIRROR_CMD}
112
Andrew Geisslercd1b0ac2019-05-30 11:18:45 -0500113RUN pip3 install \
Andrew Geissler0205e8d2016-08-10 07:46:19 -0500114 tox \
Andrew Geisslercd1b0ac2019-05-30 11:18:45 -0500115 requests \
Michael Sheposa4d6d3d2019-08-15 17:11:56 -0500116 retrying \
Matthew Barth04881eb2019-09-30 13:28:18 -0500117 websocket-client \
Alanny Lopez8594e432017-05-17 15:42:59 -0500118 json2yaml \
George Keishing22de2382024-09-09 20:27:09 +0530119 robotframework==7.0.1 \
George Keishing09dcd892022-08-02 08:12:15 -0500120 robotframework-requests \
121 robotframework-jsonlibrary \
Andrew Geissler0205e8d2016-08-10 07:46:19 -0500122 robotframework-sshlibrary \
Sunil M55d0d752018-03-22 07:04:17 -0500123 robotframework-scplibrary \
George Keishing0e5dd8a2018-12-02 23:17:59 -0600124 pysnmp \
Jian Zhang8b362562022-09-22 21:21:15 +0800125 redfish>=3.1.7 \
George Keishing26dd8e12019-02-26 12:31:11 -0600126 beautifulsoup4 --upgrade \
George Keishing882254f2019-03-05 13:55:29 -0600127 lxml \
George Keishing428553d2019-04-02 10:04:11 -0500128 jsonschema \
George Keishingae29c892019-10-04 10:49:03 -0500129 redfishtool \
Anusha Dathatri39b62802019-12-18 04:01:45 -0600130 redfish_utilities \
131 robotframework-httplibrary \
Rahul Maheshwari744b3bb2023-09-20 10:12:47 -0500132 robotframework-seleniumlibrary==6.0.0 \
133 robotframework-xvfb==1.2.2 \
Anusha Dathatri39b62802019-12-18 04:01:45 -0600134 robotframework-angularjs \
135 scp \
Rahul Maheshwari744b3bb2023-09-20 10:12:47 -0500136 selenium==4.8.2 \
Anusha Dathatri39b62802019-12-18 04:01:45 -0600137 urllib3 \
George Keishing092ec342021-08-04 01:01:51 -0500138 click \
Rahul Maheshwari744b3bb2023-09-20 10:12:47 -0500139 xvfbwrapper==0.2.9
Anusha Dathatri39b62802019-12-18 04:01:45 -0600140
Rahul Maheshwari744b3bb2023-09-20 10:12:47 -0500141RUN 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 -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}
Nan Zhouc2796fe2022-01-28 21:28:00 +0000147RUN grep -q ${UID} /etc/passwd || useradd -d ${HOME} -l -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
Patrick Williams476a7e92022-12-06 09:52:53 -0600158 PROXY_ARGS="--build-arg http_proxy=${http_proxy} --build-arg https_proxy=${http_proxy}"
Lei YUd3748742020-05-12 19:34:26 +0800159fi
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}"