Skip to content
This repository has been archived by the owner on Jun 22, 2024. It is now read-only.

Commit

Permalink
Changed Debian mirrors to Hong Kong. Added browser version to NodeFir…
Browse files Browse the repository at this point in the history
…efox Dockerfile. Added shell variables for build-step-2.sh. Fixed echo statements to print the VERSION and BUILD_DATE. Added README file in NodeFirefox with build instructions. Added generate.sh script to build-step-2.sh and used Dockerfile.arm64 as the source.
  • Loading branch information
jamesmortensen committed Nov 11, 2021
1 parent d62f6cf commit 547a95d
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 42 deletions.
38 changes: 11 additions & 27 deletions NodeFirefox/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion NodeFirefox/Dockerfile-geckodriver-arm64
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
11 changes: 8 additions & 3 deletions NodeFirefox/Dockerfile.arm64
Original file line number Diff line number Diff line change
@@ -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/*
Expand All @@ -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
59 changes: 59 additions & 0 deletions NodeFirefox/README.md
Original file line number Diff line number Diff line change
@@ -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
33 changes: 24 additions & 9 deletions NodeFirefox/build-step-2.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/bin/bash

BUILD_DATE=$(date +'%Y%m%d')
DOCKERDEB=false # if using Docker Desktop, set to false

if [[ $DOCKERDEB == true ]]
Expand All @@ -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
4 changes: 2 additions & 2 deletions StandaloneFirefox/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
15 changes: 15 additions & 0 deletions retag-latest-images-as-today.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 547a95d

Please sign in to comment.