diff --git a/NodeFirefox/Dockerfile b/NodeFirefox/Dockerfile index 524b1fe25..6ee6943e9 100644 --- a/NodeFirefox/Dockerfile +++ b/NodeFirefox/Dockerfile @@ -2,44 +2,28 @@ # NOTE: DO *NOT* EDIT THIS FILE. IT IS GENERATED. # PLEASE UPDATE Dockerfile.txt INSTEAD OF THIS FILE # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -FROM selenium/node-base:4.0.0-20211013 -LABEL authors=SeleniumHQ +FROM local-seleniarm/node-base:4.0.0-20211111 +LABEL authors=SeleniumHQ,sj26,jamesmortensen + +#FROM local-seleniarm/node-base:4.0.0-20211018 +#LABEL authors=SeleniumHQ,sj26,jamesmortensen USER root #========= # Firefox #========= -ARG FIREFOX_VERSION=latest -RUN FIREFOX_DOWNLOAD_URL=$(if [ $FIREFOX_VERSION = "latest" ] || [ $FIREFOX_VERSION = "nightly-latest" ] || [ $FIREFOX_VERSION = "devedition-latest" ] || [ $FIREFOX_VERSION = "esr-latest" ]; then echo "https://download.mozilla.org/?product=firefox-$FIREFOX_VERSION-ssl&os=linux64&lang=en-US"; else echo "https://download-installer.cdn.mozilla.net/pub/firefox/releases/$FIREFOX_VERSION/linux-x86_64/en-US/firefox-$FIREFOX_VERSION.tar.bz2"; fi) \ +RUN echo "deb http://ftp.hk.debian.org/debian/ sid main" >> /etc/apt/sources.list \ && apt-get update -qqy \ - && apt-get -qqy --no-install-recommends install firefox libavcodec-extra \ - && rm -rf /var/lib/apt/lists/* /var/cache/apt/* \ - && wget --no-verbose -O /tmp/firefox.tar.bz2 $FIREFOX_DOWNLOAD_URL \ - && apt-get -y purge firefox \ - && rm -rf /opt/firefox \ - && tar -C /opt -xjf /tmp/firefox.tar.bz2 \ - && rm /tmp/firefox.tar.bz2 \ - && mv /opt/firefox /opt/firefox-$FIREFOX_VERSION \ - && ln -fs /opt/firefox-$FIREFOX_VERSION/firefox /usr/bin/firefox + && apt-get -qqy install firefox-esr libavcodec-extra \ + && rm -rf /var/lib/apt/lists/* /var/cache/apt/* -#============ -# GeckoDriver -#============ -ARG GECKODRIVER_VERSION=latest -RUN GK_VERSION=$(if [ ${GECKODRIVER_VERSION:-latest} = "latest" ]; then echo "0.30.0"; else echo $GECKODRIVER_VERSION; fi) \ - && echo "Using GeckoDriver version: "$GK_VERSION \ - && wget --no-verbose -O /tmp/geckodriver.tar.gz https://github.com/mozilla/geckodriver/releases/download/v$GK_VERSION/geckodriver-v$GK_VERSION-linux64.tar.gz \ - && rm -rf /opt/geckodriver \ - && tar -C /opt -zxf /tmp/geckodriver.tar.gz \ - && rm /tmp/geckodriver.tar.gz \ - && mv /opt/geckodriver /opt/geckodriver-$GK_VERSION \ - && chmod 755 /opt/geckodriver-$GK_VERSION \ - && ln -fs /opt/geckodriver-$GK_VERSION /usr/bin/geckodriver +# geckodriver was built using the local-seleniarm/geckodriver-arm64 Debian image +COPY geckodriver /usr/local/bin/ USER 1200 #============================================ # Dumping Browser name and version for config #============================================ -RUN echo "firefox" > /opt/selenium/browser_name +RUN echo "firefox" > /opt/selenium/browser_name \ No newline at end of file diff --git a/NodeFirefox/Dockerfile-geckodriver-arm64 b/NodeFirefox/Dockerfile-geckodriver-arm64 index 273d94e31..9e3be118f 100644 --- a/NodeFirefox/Dockerfile-geckodriver-arm64 +++ b/NodeFirefox/Dockerfile-geckodriver-arm64 @@ -11,7 +11,7 @@ USER root # Debugging #=========== WORKDIR /opt -RUN echo "deb http://http.us.debian.org/debian/ sid main" >> /etc/apt/sources.list \ +RUN echo "deb http://ftp.hk.debian.org/debian/ sid main" >> /etc/apt/sources.list \ && apt-get update -qqy \ && apt install gcc build-essential git vim cargo -y \ && curl https://sh.rustup.rs -sSf | bash -s -- -y \ diff --git a/NodeFirefox/Dockerfile.arm64 b/NodeFirefox/Dockerfile.arm64 index 8052b8479..b4a8bdb00 100644 --- a/NodeFirefox/Dockerfile.arm64 +++ b/NodeFirefox/Dockerfile.arm64 @@ -1,12 +1,12 @@ -FROM local-seleniarm/node-base:4.0.0-20211018 -LABEL authors=SeleniumHQ,sj26,jamesmortensen +#FROM local-seleniarm/node-base:4.0.0-20211018 +#LABEL authors=SeleniumHQ,sj26,jamesmortensen USER root #========= # Firefox #========= -RUN echo "deb http://http.us.debian.org/debian/ sid main" >> /etc/apt/sources.list \ +RUN echo "deb http://ftp.hk.debian.org/debian/ sid main" >> /etc/apt/sources.list \ && apt-get update -qqy \ && apt-get -qqy install firefox-esr libavcodec-extra \ && rm -rf /var/lib/apt/lists/* /var/cache/apt/* @@ -15,3 +15,8 @@ RUN echo "deb http://http.us.debian.org/debian/ sid main" >> /etc/apt/sources.li COPY geckodriver /usr/local/bin/ USER 1200 + +#============================================ +# Dumping Browser name and version for config +#============================================ +RUN echo "firefox" > /opt/selenium/browser_name \ No newline at end of file diff --git a/NodeFirefox/README.md b/NodeFirefox/README.md new file mode 100644 index 000000000..29dd84065 --- /dev/null +++ b/NodeFirefox/README.md @@ -0,0 +1,59 @@ +## Building NodeFirefox and StandaloneFirefox for ARM64 + +I haven't located a geckdriver binary for Debian, so we'll build it from source. Unfortunately, the build step cannot yet be automated. Trying to run it as part of a docker build or even using docker exec causes the build to fail for reasons unknown to me. + +As a result, I split the build process into various steps: + +### Step 0 + +Make sure the local-seleniarm/base:latest and local-seleniarm/node-base:latest have been built using the command that builds all of the other images. If you haven't yet done this, run this from the root of the repository. + +``` +$ sh build.sh +``` + +Before proceeding, verify that local-seleniarm/base:latest and local-seleniarm/node-base:latest exist by using `docker image ls`. + + +### Step 1 + +In Step 1, we'll build the geckodriver. The geckodriver must be built specifically for Debian and specifically for the ARM64 platform, and we'll use an intermediate, throwaway Debian container to automatically setup the build environment by installing all of the needed dependencies. Once the build environment is setup, we'll need to manually run the compile step. To start this process, run the following command from the NodeFirefox working directory: + +``` +$ cd NodeFirefox +$ sh build-step-1.sh # This installs dependencies and drops you into a container bash shell +``` + +Once the dependencies are installed, we'll automatically drop into the container's shell in the `/opt/geckodriver` directory. At this stage, run this command: + +``` +$ sh build-geckodriver-arm64.sh +``` + +This uses Rust and cargo to build geckodriver. Afterwards, the script copies the binary to `/media/share` on the host. The script then moves it to the NodeFirefox directory where it will be copied into the NodeFirefox image in the next step. Once built, exit the container: + +``` +$ exit +``` + +Before proceeding to the next step, verify the geckodriver binary is inside the NodeFirefox folder. + + +### Step 2 + +At this stage, we're ready to build both NodeFirefox and StandaloneFirefox. To build these images, run the following command: + +``` +$ sh build-step-2.sh +``` + +After this completes, we see all of the container images, both with the latest tag and today's date, using `docker image ls`. + + +## Running the StandaloneFirefox image + +``` +$ docker run --rm -it --shm-size 3g -p 4444:4444 -p 5900:5900 -p 7900:7900 local-seleniarm/standalone-firefox:latest +``` + +As with the x86_64 images from upstream, this also includes noVNC on port 7900, which we can access via http://localhost:7900 diff --git a/NodeFirefox/build-step-2.sh b/NodeFirefox/build-step-2.sh index 64853f77e..e0711fd39 100644 --- a/NodeFirefox/build-step-2.sh +++ b/NodeFirefox/build-step-2.sh @@ -1,6 +1,5 @@ #!/bin/bash -BUILD_DATE=$(date +'%Y%m%d') DOCKERDEB=false # if using Docker Desktop, set to false if [[ $DOCKERDEB == true ]] @@ -12,19 +11,35 @@ else cp /media/host/geckodriver . fi +echo 'Generate the Dockerfile.arm64...' +BUILD_DATE=$(date +'%Y%m%d') +VERSION=4.0.0 +NAMESPACE=local-seleniarm +AUTHORS=SeleniumHQ,sj26,jamesmortensen + +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}-${BUILD_DATE} >> ./Dockerfile +echo LABEL authors="$AUTHORS" >> ./Dockerfile +echo "" >> ./Dockerfile +cat ./Dockerfile.arm64 >> ./Dockerfile + + -echo 'Building Seleniarm/NodeFirefox:4.0.0-$BUILD_DATE' -docker buildx build --platform linux/arm64 -f Dockerfile.arm64 -t local-seleniarm/node-firefox:4.0.0-$BUILD_DATE . -docker tag local-seleniarm/node-firefox:4.0.0-$BUILD_DATE local-seleniarm/node-firefox:latest +echo "Building Seleniarm/NodeFirefox:$VERSION-$BUILD_DATE" +docker buildx build --platform linux/arm64 -f Dockerfile -t local-seleniarm/node-firefox:$VERSION-$BUILD_DATE . +docker tag local-seleniarm/node-firefox:$VERSION-$BUILD_DATE local-seleniarm/node-firefox:latest # Generate the Seleniarm/StandaloneFirefox Dockerfile -cd ../Standalone && sh generate.sh StandaloneFirefox node-firefox 4.0.0-$BUILD_DATE local-seleniarm SeleniumHQ,sj26,james +cd ../Standalone && sh generate.sh StandaloneFirefox node-firefox $VERSION-$BUILD_DATE $NAMESPACE $AUTHORS cd ../StandaloneFirefox -echo 'Building Seleniarm/StandaloneFirefox:4.0.0-$BUILD_DATE' -docker buildx build --platform linux/arm64 -f Dockerfile -t local-seleniarm/standalone-firefox:4.0.0-$BUILD_DATE . -docker tag local-seleniarm/standalone-firefox:4.0.0-$BUILD_DATE local-seleniarm/standalone-firefox:latest +echo "Building Seleniarm/StandaloneFirefox:$VERSION-$BUILD_DATE" +docker buildx build --platform linux/arm64 -f Dockerfile -t local-seleniarm/standalone-firefox:$VERSION-$BUILD_DATE . +docker tag local-seleniarm/standalone-firefox:$VERSION-$BUILD_DATE local-seleniarm/standalone-firefox:latest # Remove geckodriver image and dependencies if build is successful, since it's 4.9GB! -docker image rm local-seleniarm/geckodriver-arm64:4.0.0-$BUILD_DATE +docker image rm local-seleniarm/geckodriver-arm64:$VERSION-$BUILD_DATE diff --git a/StandaloneFirefox/Dockerfile b/StandaloneFirefox/Dockerfile index ee26e7617..a68c2ed56 100644 --- a/StandaloneFirefox/Dockerfile +++ b/StandaloneFirefox/Dockerfile @@ -2,8 +2,8 @@ # NOTE: DO *NOT* EDIT THIS FILE. IT IS GENERATED. # PLEASE UPDATE Dockerfile.txt INSTEAD OF THIS FILE # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -FROM local-seleniarm/node-firefox:4.0.0-20211021 -LABEL authors=SeleniumHQ,sj26,james +FROM local-seleniarm/node-firefox:4.0.0-20211111 +LABEL authors=SeleniumHQ,sj26,jamesmortensen USER 1200 diff --git a/retag-latest-images-as-today.sh b/retag-latest-images-as-today.sh new file mode 100644 index 000000000..a032e7495 --- /dev/null +++ b/retag-latest-images-as-today.sh @@ -0,0 +1,15 @@ +# This script retags all of the latest images with the current date tag, in case we want to rebuild images +# without rebuilding from scratch. + +BUILD_DATE=$(date +'%Y%m%d') +VERSION=4.0.0 +NAMESPACE=local-seleniarm + +docker tag $NAMESPACE/base:latest $NAMESPACE/base:$VERSION-$BUILD_DATE +docker tag $NAMESPACE/hub:latest $NAMESPACE/hub:$VERSION-$BUILD_DATE +docker tag $NAMESPACE/node-base:latest $NAMESPACE/node-base:$VERSION-$BUILD_DATE +docker tag $NAMESPACE/node-chromium:latest $NAMESPACE/node-chromium:$VERSION-$BUILD_DATE +docker tag $NAMESPACE/standalone-chromium:latest $NAMESPACE/standalone-chromium:$VERSION-$BUILD_DATE + +docker tag $NAMESPACE/node-firefox:latest $NAMESPACE/node-firefox:$VERSION-$BUILD_DATE +docker tag $NAMESPACE/standalone-firefox:latest $NAMESPACE/standalone-firefox:$VERSION-$BUILD_DATE