From 0a8f87a33ac96baf7bc3901cc36b7bd44e52ecfd Mon Sep 17 00:00:00 2001 From: James Date: Thu, 30 Sep 2021 11:23:58 +0530 Subject: [PATCH 1/2] Added build.sh script to build the images locally for the ARM64 platform. Tested only with Chromium standalone at the moment. Added README documentation. Updated NodeChromium and Base to install Chromium and deal with some base platform differences, such as Chromium only being available on Debian instead of Ubuntu. --- Base/Dockerfile | 15 +++++++----- Hub/Dockerfile | 4 ++-- NodeBase/Dockerfile | 8 +++---- NodeBase/Dockerfile.txt | 4 ++-- NodeChromium/Dockerfile | 33 +++++++++++++++++++++++++++ NodeChromium/Dockerfile.txt | 26 +++++++++++++++++++++ NodeChromium/Dockerfile.ubuntubad | 38 +++++++++++++++++++++++++++++++ NodeChromium/generate.sh | 13 +++++++++++ NodeChromium/wrap_chromium_binary | 12 ++++++++++ README.md | 37 ++++++++++++++++++++++++++++++ StandaloneChromium/Dockerfile | 28 +++++++++++++++++++++++ build-amd64.sh | 30 ++++++++++++++++++++++++ build.sh | 30 ++++++++++++++++++++++++ 13 files changed, 264 insertions(+), 14 deletions(-) create mode 100644 NodeChromium/Dockerfile create mode 100644 NodeChromium/Dockerfile.txt create mode 100644 NodeChromium/Dockerfile.ubuntubad create mode 100755 NodeChromium/generate.sh create mode 100755 NodeChromium/wrap_chromium_binary create mode 100644 StandaloneChromium/Dockerfile create mode 100644 build-amd64.sh create mode 100644 build.sh diff --git a/Base/Dockerfile b/Base/Dockerfile index 43e0beb7c..aef453003 100644 --- a/Base/Dockerfile +++ b/Base/Dockerfile @@ -1,16 +1,19 @@ -FROM ubuntu:focal-20210416 +# FROM ubuntu:focal-20210416 +#FROM ubuntu:focal-20210827 +FROM debian:latest LABEL authors="Selenium " #================================================ # Customize sources for apt-get #================================================ -RUN echo "deb http://archive.ubuntu.com/ubuntu focal main universe\n" > /etc/apt/sources.list \ - && echo "deb http://archive.ubuntu.com/ubuntu focal-updates main universe\n" >> /etc/apt/sources.list \ - && echo "deb http://security.ubuntu.com/ubuntu focal-security main universe\n" >> /etc/apt/sources.list +#RUN echo "deb http://archive.ubuntu.com/ubuntu focal main universe\n" > /etc/apt/sources.list \ +# && echo "deb http://archive.ubuntu.com/ubuntu focal-updates main universe\n" >> /etc/apt/sources.list \ +# && echo "deb http://security.ubuntu.com/ubuntu focal-security main universe\n" >> /etc/apt/sources.list # No interactive frontend during docker build ENV DEBIAN_FRONTEND=noninteractive \ - DEBCONF_NONINTERACTIVE_SEEN=true + DEBCONF_NONINTERACTIVE_SEEN=true \ + ARCH=arm64 #======================== # Miscellaneous packages @@ -30,7 +33,7 @@ RUN apt-get -qqy update \ supervisor \ gnupg2 \ && rm -rf /var/lib/apt/lists/* /var/cache/apt/* \ - && sed -i 's/securerandom\.source=file:\/dev\/random/securerandom\.source=file:\/dev\/urandom/' ./usr/lib/jvm/java-11-openjdk-amd64/conf/security/java.security + && sed -i 's/securerandom\.source=file:\/dev\/random/securerandom\.source=file:\/dev\/urandom/' ./usr/lib/jvm/java-11-openjdk-$ARCH/conf/security/java.security #=================== # Timezone settings diff --git a/Hub/Dockerfile b/Hub/Dockerfile index 65e5b065b..1a629d68f 100644 --- a/Hub/Dockerfile +++ b/Hub/Dockerfile @@ -2,8 +2,8 @@ # NOTE: DO *NOT* EDIT THIS FILE. IT IS GENERATED. # PLEASE UPDATE Dockerfile.txt INSTEAD OF THIS FILE # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -FROM selenium/base:4.0.0-rc-2-prerelease-20210923 -LABEL authors=SeleniumHQ +FROM local-seleniarm/base:4.0.0-rc-2-prerelease-20210930 +LABEL authors=james USER 1200 diff --git a/NodeBase/Dockerfile b/NodeBase/Dockerfile index bd4e3686a..ba3214203 100644 --- a/NodeBase/Dockerfile +++ b/NodeBase/Dockerfile @@ -2,8 +2,8 @@ # NOTE: DO *NOT* EDIT THIS FILE. IT IS GENERATED. # PLEASE UPDATE Dockerfile.txt INSTEAD OF THIS FILE # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -FROM selenium/base:4.0.0-rc-2-prerelease-20210923 -LABEL authors=SeleniumHQ +FROM local-seleniarm/base:4.0.0-rc-2-prerelease-20210930 +LABEL authors=james USER root @@ -28,7 +28,7 @@ ENV LANG ${LANGUAGE} # Layer size: small: ~9 MB MB (with --no-install-recommends) RUN apt-get -qqy update \ && apt-get -qqy --no-install-recommends install \ - language-pack-en \ + #language-pack-en \ tzdata \ locales \ && locale-gen ${LANGUAGE} \ @@ -84,7 +84,7 @@ RUN apt-get -qqy update \ fonts-ipafont-gothic \ fonts-wqy-zenhei \ fonts-tlwg-loma-otf \ - ttf-ubuntu-font-family \ + # ttf-ubuntu-font-family \ && rm -rf /var/lib/apt/lists/* \ && apt-get -qyy clean diff --git a/NodeBase/Dockerfile.txt b/NodeBase/Dockerfile.txt index 5ffe33fd1..ef1842327 100644 --- a/NodeBase/Dockerfile.txt +++ b/NodeBase/Dockerfile.txt @@ -21,7 +21,7 @@ ENV LANG ${LANGUAGE} # Layer size: small: ~9 MB MB (with --no-install-recommends) RUN apt-get -qqy update \ && apt-get -qqy --no-install-recommends install \ - language-pack-en \ + #language-pack-en \ tzdata \ locales \ && locale-gen ${LANGUAGE} \ @@ -77,7 +77,7 @@ RUN apt-get -qqy update \ fonts-ipafont-gothic \ fonts-wqy-zenhei \ fonts-tlwg-loma-otf \ - ttf-ubuntu-font-family \ + # ttf-ubuntu-font-family \ && rm -rf /var/lib/apt/lists/* \ && apt-get -qyy clean diff --git a/NodeChromium/Dockerfile b/NodeChromium/Dockerfile new file mode 100644 index 000000000..5515b0b2e --- /dev/null +++ b/NodeChromium/Dockerfile @@ -0,0 +1,33 @@ +# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +# NOTE: DO *NOT* EDIT THIS FILE. IT IS GENERATED. +# PLEASE UPDATE Dockerfile.txt INSTEAD OF THIS FILE +# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +FROM local-seleniarm/node-base:4.0.0-rc-2-prerelease-20210930 +LABEL authors=james + +USER root + +# Install Chromium Arm64 +RUN echo "deb http://http.us.debian.org/debian/ stable non-free contrib main" >> /etc/apt/sources.list \ + && apt-get update -qqy \ + # && apt-get -qqy install chromium=89.0.4389.82-1 \ + && apt-get -qqy install chromium=90.0.4430.212-1 \ + && rm -rf /var/lib/apt/lists/* /var/cache/apt/* + +#================================= +# Chromium Launch Script Wrapper +#================================= +COPY wrap_chromium_binary /opt/bin/wrap_chromium_binary +RUN /opt/bin/wrap_chromium_binary + +#============================================ +# Chromium webdriver +#============================================ +RUN apt-get update -qqy \ + && apt-get -qqy install chromium-driver \ + && rm -rf /var/lib/apt/lists/* /var/cache/apt/* + +RUN echo "chrome" > /opt/selenium/browser_name + +USER 1200 + diff --git a/NodeChromium/Dockerfile.txt b/NodeChromium/Dockerfile.txt new file mode 100644 index 000000000..ca0edc070 --- /dev/null +++ b/NodeChromium/Dockerfile.txt @@ -0,0 +1,26 @@ +USER root + +# Install Chromium Arm64 +RUN echo "deb http://http.us.debian.org/debian/ stable non-free contrib main" >> /etc/apt/sources.list \ + && apt-get update -qqy \ + # && apt-get -qqy install chromium=89.0.4389.82-1 \ + && apt-get -qqy install chromium=90.0.4430.212-1 \ + && rm -rf /var/lib/apt/lists/* /var/cache/apt/* + +#================================= +# Chromium Launch Script Wrapper +#================================= +COPY wrap_chromium_binary /opt/bin/wrap_chromium_binary +RUN /opt/bin/wrap_chromium_binary + +#============================================ +# Chromium webdriver +#============================================ +RUN apt-get update -qqy \ + && apt-get -qqy install chromium-driver \ + && rm -rf /var/lib/apt/lists/* /var/cache/apt/* + +RUN echo "chrome" > /opt/selenium/browser_name + +USER 1200 + diff --git a/NodeChromium/Dockerfile.ubuntubad b/NodeChromium/Dockerfile.ubuntubad new file mode 100644 index 000000000..dc8a4b588 --- /dev/null +++ b/NodeChromium/Dockerfile.ubuntubad @@ -0,0 +1,38 @@ +# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +# NOTE: DO *NOT* EDIT THIS FILE. IT IS GENERATED. +# PLEASE UPDATE Dockerfile.txt INSTEAD OF THIS FILE +# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +FROM local-seleniarm/node-base:4.0.0-rc-2-prerelease-20210930 +LABEL authors=james + +USER root + +RUN apt-get update && apt-get install curl wget \ + && curl http://ftp.cn.debian.org/debian/pool/main/c/chromium/chromium_90.0.4430.212-1_arm64.deb -o chromium.deb + +RUN ls chromium.deb && apt install -f ./chromium.deb + +# Install Chromium Arm64 +#RUN echo "deb http://http.us.debian.org/debian/ testing non-free contrib main" >> /etc/apt/sources.list \ +#RUN +# && apt-get update -qqy \ + # && apt-get -qqy install chromium=89.0.4389.82-1 \ +# && apt-get -qqy install chromium=94.0.4606.54 \ +# && rm -rf /var/lib/apt/lists/* /var/cache/apt/* + +#================================= +# Chromium Launch Script Wrapper +#================================= +COPY wrap_chromium_binary /opt/bin/wrap_chromium_binary +RUN /opt/bin/wrap_chromium_binary + +#============================================ +# Chromium webdriver +#============================================ +RUN apt-get update -qqy \ + && apt-get -qqy install chromium-driver \ + && rm -rf /var/lib/apt/lists/* /var/cache/apt/* + + +USER 1200 + diff --git a/NodeChromium/generate.sh b/NodeChromium/generate.sh new file mode 100755 index 000000000..8267ce323 --- /dev/null +++ b/NodeChromium/generate.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +VERSION=$1 +NAMESPACE=$2 +AUTHORS=$3 + +echo "# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" > ./Dockerfile +echo "# NOTE: DO *NOT* EDIT THIS FILE. IT IS GENERATED." >> ./Dockerfile +echo "# PLEASE UPDATE Dockerfile.txt INSTEAD OF THIS FILE" >> ./Dockerfile +echo "# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" >> ./Dockerfile +echo FROM ${NAMESPACE}/node-base:${VERSION} >> ./Dockerfile +echo LABEL authors="$AUTHORS" >> ./Dockerfile +echo "" >> ./Dockerfile +cat ./Dockerfile.txt >> ./Dockerfile diff --git a/NodeChromium/wrap_chromium_binary b/NodeChromium/wrap_chromium_binary new file mode 100755 index 000000000..0d5947cad --- /dev/null +++ b/NodeChromium/wrap_chromium_binary @@ -0,0 +1,12 @@ +#!/bin/bash + +WRAPPER_PATH=$(readlink -f /usr/bin/chromium) +BASE_PATH="$WRAPPER_PATH-base" +mv "$WRAPPER_PATH" "$BASE_PATH" + +cat > "$WRAPPER_PATH" <<_EOF +#!/bin/bash +# Note: exec -a below is a bashism. +exec -a "\$0" "$BASE_PATH" --no-sandbox "\$@" +_EOF +chmod +x "$WRAPPER_PATH" diff --git a/README.md b/README.md index f66999071..591886b58 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,40 @@ +# Docker images for Selenium, built for Debian ARM64 + +At this point, I've only updated the images for Chromium 90, the latest ARM64 build for Debian ARM64. + +## Only Building the Images + +If you want to build the images locally, without pushing to any registry, then use the build.sh script in the root of the project directory. + +The Standalone folder is the base for all Standalone${browser} images and includes a script that starts the selenium server in standalone mode. +The NodeBase folder is the base for all Node${browser} images and includes a script that starts the selenium server in node mode. + +Inside build.sh are environment variables which are used to tag the built images. If changing the Selenium version, note that you must also edit the Base/Dockerfile and change which selenium-server version is downloaded via wget. The Chromium version is set in NodeChromium/Dockerfile.txt. + +To build the images, run build.sh from the root directory of this repo: + +``` +$ sh build.sh +``` + +I have not pushed any images to the Docker registry. If you wish to push them to a registry, you may do so. For more information on older ARM64 Selenium images, see https://github.com/sj26/docker-selenium and https://hub.docker.com/u/seleniarm + +the primary motivation for creating this fork and updating the images is so I can use the noVNC client on Selenium 4.0.0. To use noVNC, make sure you open port 7900, and visit localhost:7900 in your browser. + +To start the container image, run: + +``` +$ docker run --rm -it -p 4444:4444 -p 5900:5900 -p 7900:7900 --shm-size 3g local-seleniarm/standalone-chromium:latest +``` + +Use your traditional VNC client via port 5900, and noVNC in the browser via port 7900. + + +---- +The official documentation from seleniumHQ begins here: +---- + + # Docker images for the Selenium Grid Server The project is made possible by volunteer contributors who have put in thousands of hours of their own time, diff --git a/StandaloneChromium/Dockerfile b/StandaloneChromium/Dockerfile new file mode 100644 index 000000000..fae3b5e9f --- /dev/null +++ b/StandaloneChromium/Dockerfile @@ -0,0 +1,28 @@ +# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +# NOTE: DO *NOT* EDIT THIS FILE. IT IS GENERATED. +# PLEASE UPDATE Dockerfile.txt INSTEAD OF THIS FILE +# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +FROM local-seleniarm/node-chromium:4.0.0-rc-2-prerelease-20210930 +LABEL authors=james + +USER 1200 + +#==================================== +# Scripts to run Selenium Standalone +#==================================== +COPY start-selenium-standalone.sh /opt/bin/start-selenium-standalone.sh + +#============================== +# Supervisor configuration file +#============================== +COPY selenium.conf /etc/supervisor/conf.d/ + +# Copying configuration script generator +COPY generate_config /opt/bin/generate_config + +# Boolean value, maps "--relax-checks" +ENV SE_RELAX_CHECKS true + +EXPOSE 4444 + + diff --git a/build-amd64.sh b/build-amd64.sh new file mode 100644 index 000000000..0d79aa974 --- /dev/null +++ b/build-amd64.sh @@ -0,0 +1,30 @@ +BUILD_DATE=$(date +'%Y%m%d') +VERSION=4.0.0-beta-2 +CHROMIUM=91.0.4472.124 +NAMESPACE=local-selenium +AUTHORS=james + +cd ./Base && docker buildx build --platform linux/amd64 -t $NAMESPACE/base:$VERSION-$BUILD_DATE . +echo $PWD +cd ../Hub && sh generate.sh $VERSION-$BUILD_DATE $NAMESPACE $AUTHORS \ + && docker buildx build --platform linux/amd64 -t $NAMESPACE/hub:$VERSION-$BUILD_DATE . + +cd ../NodeBase && sh generate.sh $VERSION-$BUILD_DATE $NAMESPACE $AUTHORS \ + && docker buildx build --platform linux/amd64 -t $NAMESPACE/node-base:$VERSION-$BUILD_DATE . +# && sed 's/chromium=.*/chromium=91.0.4472.124/' Dockerfile > Dockerfile \ +cd ../NodeChromium && sh generate.sh $VERSION-$BUILD_DATE $NAMESPACE $AUTHORS \ + && docker buildx build --platform linux/amd64 -t $NAMESPACE/node-chromium:$VERSION-$BUILD_DATE . + +cd ../Standalone && sh generate.sh StandaloneChromium node-chromium $VERSION-$BUILD_DATE $NAMESPACE $AUTHORS \ + && cd ../StandaloneChromium \ + && docker buildx build --platform linux/amd64 -t $NAMESPACE/standalone-chromium:$VERSION-$BUILD_DATE . + +echo "Build node-hub, node-chromium, and standalone-chromium...\n" +echo "Tagging builds...\n" + +docker tag $NAMESPACE/base:$VERSION-$BUILD_DATE $NAMESPACE/base:latest +docker tag $NAMESPACE/hub:$VERSION-$BUILD_DATE $NAMESPACE/hub:latest +docker tag $NAMESPACE/node-base:$VERSION-$BUILD_DATE $NAMESPACE/node-base:latest +docker tag $NAMESPACE/node-chromium:$VERSION-$BUILD_DATE $NAMESPACE/node-chromium:latest +docker tag $NAMESPACE/standalone-chromium:$VERSION-$BUILD_DATE $NAMESPACE/standalone-chromium:latest + diff --git a/build.sh b/build.sh new file mode 100644 index 000000000..e1f3affa9 --- /dev/null +++ b/build.sh @@ -0,0 +1,30 @@ +BUILD_DATE=$(date +'%Y%m%d') +VERSION=4.0.0-rc-2-prerelease +CHROMIUM=94.0.4606.54 +NAMESPACE=local-seleniarm +AUTHORS=james + +cd ./Base && docker buildx build --platform linux/arm64 -t $NAMESPACE/base:$VERSION-$BUILD_DATE . +echo $PWD +cd ../Hub && sh generate.sh $VERSION-$BUILD_DATE $NAMESPACE $AUTHORS \ + && docker buildx build --platform linux/arm64 -t $NAMESPACE/hub:$VERSION-$BUILD_DATE . + +cd ../NodeBase && sh generate.sh $VERSION-$BUILD_DATE $NAMESPACE $AUTHORS \ + && docker buildx build --platform linux/arm64 -t $NAMESPACE/node-base:$VERSION-$BUILD_DATE . +# && sed 's/chromium=.*/chromium=91.0.4472.124/' Dockerfile > Dockerfile \ +cd ../NodeChromium && sh generate.sh $VERSION-$BUILD_DATE $NAMESPACE $AUTHORS \ + && docker buildx build --platform linux/arm64 -t $NAMESPACE/node-chromium:$VERSION-$BUILD_DATE . + +cd ../Standalone && sh generate.sh StandaloneChromium node-chromium $VERSION-$BUILD_DATE $NAMESPACE $AUTHORS \ + && cd ../StandaloneChromium \ + && docker buildx build --platform linux/arm64 -t $NAMESPACE/standalone-chromium:$VERSION-$BUILD_DATE . + +echo "Build node-hub, node-chromium, and standalone-chromium...\n" +echo "Tagging builds...\n" + +docker tag $NAMESPACE/base:$VERSION-$BUILD_DATE $NAMESPACE/base:latest +docker tag $NAMESPACE/hub:$VERSION-$BUILD_DATE $NAMESPACE/hub:latest +docker tag $NAMESPACE/node-base:$VERSION-$BUILD_DATE $NAMESPACE/node-base:latest +docker tag $NAMESPACE/node-chromium:$VERSION-$BUILD_DATE $NAMESPACE/node-chromium:latest +docker tag $NAMESPACE/standalone-chromium:$VERSION-$BUILD_DATE $NAMESPACE/standalone-chromium:latest + From f0fe1dcd20a753c8cc438bfe4b3d26a06d43b460 Mon Sep 17 00:00:00 2001 From: James Date: Mon, 18 Oct 2021 18:45:23 +0530 Subject: [PATCH 2/2] Updated Chromium version in the README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f339c2c4f..38b725350 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Docker images for Selenium, built for Debian ARM64 -At this point, I've only updated the images for Chromium 90, the latest ARM64 build for Debian ARM64. +At this point, I've only updated the images for Chromium 93, the latest ARM64 build for Debian ARM64. ## Only Building the Images