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

Commit d88e8f0

Browse files
Merge from firefox-geckodriver-build branch
2 parents 8f82b00 + 547a95d commit d88e8f0

File tree

9 files changed

+219
-29
lines changed

9 files changed

+219
-29
lines changed

NodeFirefox/Dockerfile

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,28 @@
22
# NOTE: DO *NOT* EDIT THIS FILE. IT IS GENERATED.
33
# PLEASE UPDATE Dockerfile.txt INSTEAD OF THIS FILE
44
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
5-
FROM selenium/node-base:4.0.0-20211025
6-
LABEL authors=SeleniumHQ
5+
FROM local-seleniarm/node-base:4.0.0-20211111
6+
LABEL authors=SeleniumHQ,sj26,jamesmortensen
7+
8+
#FROM local-seleniarm/node-base:4.0.0-20211018
9+
#LABEL authors=SeleniumHQ,sj26,jamesmortensen
710

811
USER root
912

1013
#=========
1114
# Firefox
1215
#=========
13-
ARG FIREFOX_VERSION=latest
14-
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) \
16+
RUN echo "deb http://ftp.hk.debian.org/debian/ sid main" >> /etc/apt/sources.list \
1517
&& apt-get update -qqy \
16-
&& apt-get -qqy --no-install-recommends install firefox libavcodec-extra \
17-
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/* \
18-
&& wget --no-verbose -O /tmp/firefox.tar.bz2 $FIREFOX_DOWNLOAD_URL \
19-
&& apt-get -y purge firefox \
20-
&& rm -rf /opt/firefox \
21-
&& tar -C /opt -xjf /tmp/firefox.tar.bz2 \
22-
&& rm /tmp/firefox.tar.bz2 \
23-
&& mv /opt/firefox /opt/firefox-$FIREFOX_VERSION \
24-
&& ln -fs /opt/firefox-$FIREFOX_VERSION/firefox /usr/bin/firefox
18+
&& apt-get -qqy install firefox-esr libavcodec-extra \
19+
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/*
2520

26-
#============
27-
# GeckoDriver
28-
#============
29-
ARG GECKODRIVER_VERSION=latest
30-
RUN GK_VERSION=$(if [ ${GECKODRIVER_VERSION:-latest} = "latest" ]; then echo "0.30.0"; else echo $GECKODRIVER_VERSION; fi) \
31-
&& echo "Using GeckoDriver version: "$GK_VERSION \
32-
&& 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 \
33-
&& rm -rf /opt/geckodriver \
34-
&& tar -C /opt -zxf /tmp/geckodriver.tar.gz \
35-
&& rm /tmp/geckodriver.tar.gz \
36-
&& mv /opt/geckodriver /opt/geckodriver-$GK_VERSION \
37-
&& chmod 755 /opt/geckodriver-$GK_VERSION \
38-
&& ln -fs /opt/geckodriver-$GK_VERSION /usr/bin/geckodriver
21+
# geckodriver was built using the local-seleniarm/geckodriver-arm64 Debian image
22+
COPY geckodriver /usr/local/bin/
3923

4024
USER 1200
4125

4226
#============================================
4327
# Dumping Browser name and version for config
4428
#============================================
45-
RUN echo "firefox" > /opt/selenium/browser_name
29+
RUN echo "firefox" > /opt/selenium/browser_name
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
FROM local-seleniarm/node-base:latest
2+
LABEL authors=SeleniumHQ,sj26,jamesmortensen
3+
4+
##### tags
5+
# local-seleniarm/geckodriver-arm64:4.0.0-$(build_date)
6+
#####
7+
USER root
8+
9+
10+
#===========
11+
# Debugging
12+
#===========
13+
WORKDIR /opt
14+
RUN echo "deb http://ftp.hk.debian.org/debian/ sid main" >> /etc/apt/sources.list \
15+
&& apt-get update -qqy \
16+
&& apt install gcc build-essential git vim cargo -y \
17+
&& curl https://sh.rustup.rs -sSf | bash -s -- -y \
18+
&& git clone https://github.com/mozilla/geckodriver.git && cd geckodriver \
19+
&& git checkout v0.30.0
20+
21+
RUN echo "alias l='ls -ltrSha'" >> /home/seluser/.bashrc
22+
23+
COPY build-geckodriver-arm64.sh /opt/geckodriver/
24+
25+
RUN chown seluser /opt/geckodriver/build-geckodriver-arm64.sh \
26+
&& chmod 755 /opt/geckodriver/build-geckodriver-arm64.sh \
27+
&& sudo chown -R seluser /home/seluser/.rustup /home/seluser/.cargo /opt/geckodriver
28+
29+
# COPY geckodriver /usr/local/bin/
30+
# USER seluser
31+
# RUN sudo chown -R seluser /home/seluser/.rustup /home/seluser/.cargo /opt/geckodriver \
32+
# && cd /opt/geckodriver \
33+
# && cargo build \
34+
# && sudo cp target/debug/geckodriver /usr/local/bin/ \
35+
# && sudo apt remove gcc build-essential cargo
36+
37+
# WORKDIR /
38+
39+
#============
40+
# GeckoDriver
41+
#============
42+
# For arm64 we're sniffing a compatible binary out of an ubuntu package, don't look too hard!
43+
#RUN echo "Downloading Arm64 geckodriver..."
44+
# curl http://ports.ubuntu.com/pool/universe/f/firefox/firefox-geckodriver_75.0+build3-0ubuntu1_arm64.deb | dpkg-deb --fsys-tarfile - | tar -C / -x ./usr/bin/geckodriver;
45+
# curl http://ports.ubuntu.com/pool/universe/f/firefox/firefox-geckodriver_93.0+build1-0ubuntu3_arm64.deb | dpkg-deb --fsys-tarfile - | tar -C / -x ./usr/bin/geckodriver;
46+
47+
USER 1200

NodeFirefox/Dockerfile.arm64

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#FROM local-seleniarm/node-base:4.0.0-20211018
2+
#LABEL authors=SeleniumHQ,sj26,jamesmortensen
3+
4+
USER root
5+
6+
#=========
7+
# Firefox
8+
#=========
9+
RUN echo "deb http://ftp.hk.debian.org/debian/ sid main" >> /etc/apt/sources.list \
10+
&& apt-get update -qqy \
11+
&& apt-get -qqy install firefox-esr libavcodec-extra \
12+
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/*
13+
14+
# geckodriver was built using the local-seleniarm/geckodriver-arm64 Debian image
15+
COPY geckodriver /usr/local/bin/
16+
17+
USER 1200
18+
19+
#============================================
20+
# Dumping Browser name and version for config
21+
#============================================
22+
RUN echo "firefox" > /opt/selenium/browser_name

NodeFirefox/README.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
## Building NodeFirefox and StandaloneFirefox for ARM64
2+
3+
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.
4+
5+
As a result, I split the build process into various steps:
6+
7+
### Step 0
8+
9+
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.
10+
11+
```
12+
$ sh build.sh
13+
```
14+
15+
Before proceeding, verify that local-seleniarm/base:latest and local-seleniarm/node-base:latest exist by using `docker image ls`.
16+
17+
18+
### Step 1
19+
20+
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:
21+
22+
```
23+
$ cd NodeFirefox
24+
$ sh build-step-1.sh # This installs dependencies and drops you into a container bash shell
25+
```
26+
27+
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:
28+
29+
```
30+
$ sh build-geckodriver-arm64.sh
31+
```
32+
33+
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:
34+
35+
```
36+
$ exit
37+
```
38+
39+
Before proceeding to the next step, verify the geckodriver binary is inside the NodeFirefox folder.
40+
41+
42+
### Step 2
43+
44+
At this stage, we're ready to build both NodeFirefox and StandaloneFirefox. To build these images, run the following command:
45+
46+
```
47+
$ sh build-step-2.sh
48+
```
49+
50+
After this completes, we see all of the container images, both with the latest tag and today's date, using `docker image ls`.
51+
52+
53+
## Running the StandaloneFirefox image
54+
55+
```
56+
$ docker run --rm -it --shm-size 3g -p 4444:4444 -p 5900:5900 -p 7900:7900 local-seleniarm/standalone-firefox:latest
57+
```
58+
59+
As with the x86_64 images from upstream, this also includes noVNC on port 7900, which we can access via http://localhost:7900
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
cargo build && sudo cp /opt/geckodriver/target/debug/geckodriver /media/host

NodeFirefox/build-step-1.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
BUILD_DATE=$(date +'%Y%m%d')
4+
# Make sure other images are built first using build.sh
5+
# We need both the Base and NodeBase to begin building NodeFirefox
6+
7+
# Install geckodriver binary dependencies
8+
docker buildx build --platform linux/arm64 -f Dockerfile-geckodriver-arm64 -t local-seleniarm/geckodriver-arm64:4.0.0-$BUILD_DATE .
9+
10+
# build geckodriver binary and copy to build folder on host
11+
echo 'Building geckodriver must be done manually from within an intermediate container. Run ./build-geckodriver-arm64.sh on the container, then exit...'
12+
docker run --rm -it -v $PWD:/media/host -w /opt/geckodriver --name geckodriver-arm64 local-seleniarm/geckodriver-arm64:4.0.0-$BUILD_DATE bash
13+
14+
15+
echo 'After exiting, run build-step-2.sh'

NodeFirefox/build-step-2.sh

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/bin/bash
2+
3+
DOCKERDEB=false # if using Docker Desktop, set to false
4+
5+
if [[ $DOCKERDEB == true ]]
6+
then
7+
echo 'Getting geckodriver binary from the Docker Debian VM...'
8+
sh get-geckodriver.sh
9+
else
10+
echo 'Getting geckodriver from /media/host...'
11+
cp /media/host/geckodriver .
12+
fi
13+
14+
echo 'Generate the Dockerfile.arm64...'
15+
BUILD_DATE=$(date +'%Y%m%d')
16+
VERSION=4.0.0
17+
NAMESPACE=local-seleniarm
18+
AUTHORS=SeleniumHQ,sj26,jamesmortensen
19+
20+
echo "# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" > ./Dockerfile
21+
echo "# NOTE: DO *NOT* EDIT THIS FILE. IT IS GENERATED." >> ./Dockerfile
22+
echo "# PLEASE UPDATE Dockerfile.txt INSTEAD OF THIS FILE" >> ./Dockerfile
23+
echo "# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" >> ./Dockerfile
24+
echo FROM ${NAMESPACE}/node-base:${VERSION}-${BUILD_DATE} >> ./Dockerfile
25+
echo LABEL authors="$AUTHORS" >> ./Dockerfile
26+
echo "" >> ./Dockerfile
27+
cat ./Dockerfile.arm64 >> ./Dockerfile
28+
29+
30+
31+
echo "Building Seleniarm/NodeFirefox:$VERSION-$BUILD_DATE"
32+
docker buildx build --platform linux/arm64 -f Dockerfile -t local-seleniarm/node-firefox:$VERSION-$BUILD_DATE .
33+
docker tag local-seleniarm/node-firefox:$VERSION-$BUILD_DATE local-seleniarm/node-firefox:latest
34+
35+
# Generate the Seleniarm/StandaloneFirefox Dockerfile
36+
cd ../Standalone && sh generate.sh StandaloneFirefox node-firefox $VERSION-$BUILD_DATE $NAMESPACE $AUTHORS
37+
cd ../StandaloneFirefox
38+
39+
echo "Building Seleniarm/StandaloneFirefox:$VERSION-$BUILD_DATE"
40+
docker buildx build --platform linux/arm64 -f Dockerfile -t local-seleniarm/standalone-firefox:$VERSION-$BUILD_DATE .
41+
docker tag local-seleniarm/standalone-firefox:$VERSION-$BUILD_DATE local-seleniarm/standalone-firefox:latest
42+
43+
44+
# Remove geckodriver image and dependencies if build is successful, since it's 4.9GB!
45+
docker image rm local-seleniarm/geckodriver-arm64:$VERSION-$BUILD_DATE

StandaloneFirefox/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
# NOTE: DO *NOT* EDIT THIS FILE. IT IS GENERATED.
33
# PLEASE UPDATE Dockerfile.txt INSTEAD OF THIS FILE
44
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
5-
FROM selenium/node-firefox:4.0.0-20211025
6-
LABEL authors=SeleniumHQ
5+
FROM local-seleniarm/node-firefox:4.0.0-20211111
6+
LABEL authors=SeleniumHQ,sj26,jamesmortensen
77

88
USER 1200
99

retag-latest-images-as-today.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# This script retags all of the latest images with the current date tag, in case we want to rebuild images
2+
# without rebuilding from scratch.
3+
4+
BUILD_DATE=$(date +'%Y%m%d')
5+
VERSION=4.0.0
6+
NAMESPACE=local-seleniarm
7+
8+
docker tag $NAMESPACE/base:latest $NAMESPACE/base:$VERSION-$BUILD_DATE
9+
docker tag $NAMESPACE/hub:latest $NAMESPACE/hub:$VERSION-$BUILD_DATE
10+
docker tag $NAMESPACE/node-base:latest $NAMESPACE/node-base:$VERSION-$BUILD_DATE
11+
docker tag $NAMESPACE/node-chromium:latest $NAMESPACE/node-chromium:$VERSION-$BUILD_DATE
12+
docker tag $NAMESPACE/standalone-chromium:latest $NAMESPACE/standalone-chromium:$VERSION-$BUILD_DATE
13+
14+
docker tag $NAMESPACE/node-firefox:latest $NAMESPACE/node-firefox:$VERSION-$BUILD_DATE
15+
docker tag $NAMESPACE/standalone-firefox:latest $NAMESPACE/standalone-firefox:$VERSION-$BUILD_DATE

0 commit comments

Comments
 (0)