This repository has been archived by the owner on Jun 22, 2024. It is now read-only.
forked from SeleniumHQ/docker-selenium
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge from firefox-geckodriver-build branch
- Loading branch information
Showing
9 changed files
with
219 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
FROM local-seleniarm/node-base:latest | ||
LABEL authors=SeleniumHQ,sj26,jamesmortensen | ||
|
||
##### tags | ||
# local-seleniarm/geckodriver-arm64:4.0.0-$(build_date) | ||
##### | ||
USER root | ||
|
||
|
||
#=========== | ||
# Debugging | ||
#=========== | ||
WORKDIR /opt | ||
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 \ | ||
&& git clone https://github.com/mozilla/geckodriver.git && cd geckodriver \ | ||
&& git checkout v0.30.0 | ||
|
||
RUN echo "alias l='ls -ltrSha'" >> /home/seluser/.bashrc | ||
|
||
COPY build-geckodriver-arm64.sh /opt/geckodriver/ | ||
|
||
RUN chown seluser /opt/geckodriver/build-geckodriver-arm64.sh \ | ||
&& chmod 755 /opt/geckodriver/build-geckodriver-arm64.sh \ | ||
&& sudo chown -R seluser /home/seluser/.rustup /home/seluser/.cargo /opt/geckodriver | ||
|
||
# COPY geckodriver /usr/local/bin/ | ||
# USER seluser | ||
# RUN sudo chown -R seluser /home/seluser/.rustup /home/seluser/.cargo /opt/geckodriver \ | ||
# && cd /opt/geckodriver \ | ||
# && cargo build \ | ||
# && sudo cp target/debug/geckodriver /usr/local/bin/ \ | ||
# && sudo apt remove gcc build-essential cargo | ||
|
||
# WORKDIR / | ||
|
||
#============ | ||
# GeckoDriver | ||
#============ | ||
# For arm64 we're sniffing a compatible binary out of an ubuntu package, don't look too hard! | ||
#RUN echo "Downloading Arm64 geckodriver..." | ||
# 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; | ||
# 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; | ||
|
||
USER 1200 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#FROM local-seleniarm/node-base:4.0.0-20211018 | ||
#LABEL authors=SeleniumHQ,sj26,jamesmortensen | ||
|
||
USER root | ||
|
||
#========= | ||
# Firefox | ||
#========= | ||
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/* | ||
|
||
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
|
||
cargo build && sudo cp /opt/geckodriver/target/debug/geckodriver /media/host |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
|
||
BUILD_DATE=$(date +'%Y%m%d') | ||
# Make sure other images are built first using build.sh | ||
# We need both the Base and NodeBase to begin building NodeFirefox | ||
|
||
# Install geckodriver binary dependencies | ||
docker buildx build --platform linux/arm64 -f Dockerfile-geckodriver-arm64 -t local-seleniarm/geckodriver-arm64:4.0.0-$BUILD_DATE . | ||
|
||
# build geckodriver binary and copy to build folder on host | ||
echo 'Building geckodriver must be done manually from within an intermediate container. Run ./build-geckodriver-arm64.sh on the container, then exit...' | ||
docker run --rm -it -v $PWD:/media/host -w /opt/geckodriver --name geckodriver-arm64 local-seleniarm/geckodriver-arm64:4.0.0-$BUILD_DATE bash | ||
|
||
|
||
echo 'After exiting, run build-step-2.sh' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/bin/bash | ||
|
||
DOCKERDEB=false # if using Docker Desktop, set to false | ||
|
||
if [[ $DOCKERDEB == true ]] | ||
then | ||
echo 'Getting geckodriver binary from the Docker Debian VM...' | ||
sh get-geckodriver.sh | ||
else | ||
echo 'Getting geckodriver from /media/host...' | ||
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:$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 $VERSION-$BUILD_DATE $NAMESPACE $AUTHORS | ||
cd ../StandaloneFirefox | ||
|
||
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:$VERSION-$BUILD_DATE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |