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

Commit

Permalink
Merge branch 'trunk' into 4.20.0
Browse files Browse the repository at this point in the history
  • Loading branch information
VietND96 authored Apr 25, 2024
2 parents 0d82ddc + 496b79a commit 2b2e490
Show file tree
Hide file tree
Showing 22 changed files with 1,572 additions and 21 deletions.
403 changes: 403 additions & 0 deletions .circleci/config.yml

Large diffs are not rendered by default.

59 changes: 59 additions & 0 deletions .github/workflows/build-test-multi-arch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Build & test multi-arch

on:
# push:
# branches:
# - multi-arch-tests
# - qemu-user-static
# pull_request:
# branches:
# - trunk
workflow_dispatch:

jobs:
build-and-test-multi-arch:
# Skip job based on the commit message, only works in push to branches for now
if: contains(toJson(github.event.commits), '[skip ci]') == false
name: Build & test multi-arch
runs-on: ubuntu-20.04
strategy:
matrix:
use-random-user: [false, true]
arch: [amd64, arm64]
fail-fast: false

steps:
- uses: actions/checkout@v1
- name: Output Docker info
run: docker info
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Get branch name (only for push to branch)
if: github.event_name == 'push'
run: echo "BRANCH=$(echo ${PUSH_BRANCH##*/})" >> $GITHUB_ENV
env:
PUSH_BRANCH: ${{ github.ref }}
- name: Get target branch name (only for PRs)
if: github.event_name == 'pull_request'
run: echo "BRANCH=$(echo ${TARGET_BRANCH##*/})" >> $GITHUB_ENV
env:
TARGET_BRANCH: ${{ github.head_ref }}
- name: Output branch name
run: echo ${BRANCH}
- name: Sets build date
run: echo "BUILD_DATE=$(date '+%Y%m%d')" >> $GITHUB_ENV
- name: Build Docker images
run: VERSION=${BRANCH} BUILD_DATE=${BUILD_DATE} ARCH=${ARCH} make build_multi
if: matrix.arch == 'arm64' && matrix.use-random-user == 'false'
- name: Test Docker images
run: |
docker run -d --platform linux/${ARCH} --rm -it -p 4444:4444 -p 7900:7900 --shm-size 2g selenium/standalone-firefox:${BRANCH}-${BUILD_DATE}
USE_RANDOM_USER_ID=${USE_RANDOM_USER} VERSION=${BRANCH} BUILD_DATE=${BUILD_DATE} ARCH=${ARCH} SKIP_BUILD=true make test_firefox_standalone_multi
#USE_RANDOM_USER_ID=${USE_RANDOM_USER} VERSION=${BRANCH} BUILD_DATE=${BUILD_DATE} ARCH=${ARCH} SKIP_BUILD=true make test_chromium_standalone_multi
env:
USE_RANDOM_USER: ${{ matrix.use-random-user }}
ARCH: ${{ matrix.arch }}
if: matrix.arch == 'arm64' && matrix.use-random-user == 'false'

2 changes: 1 addition & 1 deletion Base/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:jammy-20240405
FROM debian:bookworm
LABEL authors="Selenium <[email protected]>"

# Arguments to define the version of dependencies to download
Expand Down
143 changes: 143 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ MAJOR_MINOR_PATCH := $(word 1,$(subst -, ,$(TAG_VERSION)))
FFMPEG_TAG_VERSION := $(or $(FFMPEG_TAG_VERSION),$(FFMPEG_TAG_VERSION),ffmpeg-7.0)
FFMPEG_BASED_NAME := $(or $(FFMPEG_BASED_NAME),$(FFMPEG_BASED_NAME),ndviet)
FFMPEG_BASED_TAG := $(or $(FFMPEG_BASED_TAG),$(FFMPEG_BASED_TAG),7.0-ubuntu2204)
PLATFORMS := $(or $(PLATFORMS),$(PLATFORMS),linux/arm64)

all: hub \
distributor \
Expand Down Expand Up @@ -178,6 +179,77 @@ edge_upgrade_version:
docker run --rm $(NAME)/standalone-edge:$(TAG_VERSION) microsoft-edge --version
docker run --rm $(NAME)/standalone-edge:$(TAG_VERSION) msedgedriver --version

# Register linux/arm64 and linux/arm/v7 architectures for building with BuildKit
# docker run --rm --privileged aptman/qus -s -- -p # for actions
qemu_user_static:
docker run --rm --privileged aptman/qus -- -r ; \
docker run --rm --privileged aptman/qus -s -- -p

# Build multi-arch images
all_multi: base_multi \
hub_multi \
chromium_multi \
firefox_multi \
docker_multi \
standalone_chromium_multi \
standalone_firefox_multi \
standalone_docker_multi \
distributor_multi \
router_multi \
sessions_multi \
sessionqueue_multi \
event_bus_multi \
video_multi

build_multi: all_multi

ci_multi: build_multi test_multi_arch

base_multi: qemu_user_static
cd ./Base && docker buildx build --platform $(PLATFORMS) $(BUILD_ARGS) --build-arg VERSION=$(BASE_VERSION) --build-arg RELEASE=$(BASE_RELEASE) -t $(NAME)/base:$(TAG_VERSION) .

hub_multi: base_multi
cd ./Hub && docker buildx build --platform $(PLATFORMS) $(BUILD_ARGS) $(FROM_IMAGE_ARGS) -t $(NAME)/hub:$(TAG_VERSION) .

distributor_multi:
cd ./Distributor && docker buildx build --platform $(PLATFORMS) $(BUILD_ARGS) $(FROM_IMAGE_ARGS) -t $(NAME)/distributor:$(TAG_VERSION) .

router_multi:
cd ./Router && docker buildx build --platform $(PLATFORMS) $(BUILD_ARGS) $(FROM_IMAGE_ARGS) -t $(NAME)/router:$(TAG_VERSION) .

sessions_multi:
cd ./Sessions && docker buildx build --platform $(PLATFORMS) $(BUILD_ARGS) $(FROM_IMAGE_ARGS) -t $(NAME)/sessions:$(TAG_VERSION) .

sessionqueue_multi:
cd ./SessionQueue && docker buildx build --platform $(PLATFORMS) $(BUILD_ARGS) $(FROM_IMAGE_ARGS) -t $(NAME)/session-queue:$(TAG_VERSION) .

event_bus_multi: base_multi
cd ./EventBus && docker buildx build --platform $(PLATFORMS) $(BUILD_ARGS) $(FROM_IMAGE_ARGS) -t $(NAME)/event-bus:$(TAG_VERSION) .

node_base_multi: base_multi
cd ./NodeBase && docker buildx build --platform $(PLATFORMS) $(BUILD_ARGS) $(FROM_IMAGE_ARGS) -t $(NAME)/node-base:$(TAG_VERSION) .

chromium_multi: node_base_multi
cd ./NodeChromium && docker buildx build --platform $(PLATFORMS) $(BUILD_ARGS) $(FROM_IMAGE_ARGS) -t $(NAME)/node-chromium:$(TAG_VERSION) .

firefox_multi: node_base_multi
cd ./NodeFirefox && docker buildx build -f Dockerfile.multi-arch --platform $(PLATFORMS) $(BUILD_ARGS) $(FROM_IMAGE_ARGS) -t $(NAME)/node-firefox:$(TAG_VERSION) .

docker_multi: base_multi
cd ./NodeDocker && docker buildx build --platform $(PLATFORMS) $(BUILD_ARGS) $(FROM_IMAGE_ARGS) -t $(NAME)/node-docker:$(TAG_VERSION) .

standalone_firefox_multi: firefox_multi
cd ./Standalone && docker buildx build --platform $(PLATFORMS) $(BUILD_ARGS) $(FROM_IMAGE_ARGS) --build-arg BASE=node-firefox -t $(NAME)/standalone-firefox:$(TAG_VERSION) .

standalone_chromium_multi: chromium_multi
cd ./Standalone && docker buildx build --platform $(PLATFORMS) $(BUILD_ARGS) $(FROM_IMAGE_ARGS) --build-arg BASE=node-chromium -t $(NAME)/standalone-chromium:$(TAG_VERSION) .

standalone_docker_multi: docker_multi
cd ./StandaloneDocker && docker buildx build --platform $(PLATFORMS) $(BUILD_ARGS) $(FROM_IMAGE_ARGS) -t $(NAME)/standalone-docker:$(TAG_VERSION) .

video_multi:
cd ./Video && docker buildx build --platform $(PLATFORMS) $(BUILD_ARGS) --build-arg NAMESPACE=$(FFMPEG_BASED_NAME) --build-arg BASED_TAG=$(FFMPEG_BASED_TAG) -t $(NAME)/video:$(FFMPEG_TAG_VERSION)-$(BUILD_DATE) .

# https://github.com/SeleniumHQ/docker-selenium/issues/992
# Additional tags for browser images
tag_and_push_browser_images: tag_and_push_chrome_images tag_and_push_firefox_images tag_and_push_edge_images
Expand Down Expand Up @@ -210,6 +282,58 @@ tag_latest:
docker tag $(NAME)/standalone-docker:$(TAG_VERSION) $(NAME)/standalone-docker:latest
docker tag $(NAME)/video:$(FFMPEG_TAG_VERSION)-$(BUILD_DATE) $(NAME)/video:latest

# Additional tags for browser images
tag_and_push_multi_arch_browser_images: tag_and_push_multi_arch_chromium_images tag_and_push_multi_arch_firefox_images

tag_and_push_multi_arch_chromium_images:
./tag_and_push_multi-arch_browser_images.sh $(VERSION) $(BUILD_DATE) $(NAMESPACE) $(PUSH_IMAGE) chromium

tag_and_push_multi_arch_firefox_images:
./tag_and_push_multi-arch_browser_images.sh $(VERSION) $(BUILD_DATE) $(NAMESPACE) $(PUSH_IMAGE) firefox

tag_major_minor_multi_arch:
./tag_and_push_multi-arch_major_minor.sh $(VERSION) $(BUILD_DATE) $(NAMESPACE) $(PUSH_IMAGE) base
./tag_and_push_multi-arch_major_minor.sh $(VERSION) $(BUILD_DATE) $(NAMESPACE) $(PUSH_IMAGE) hub
./tag_and_push_multi-arch_major_minor.sh $(VERSION) $(BUILD_DATE) $(NAMESPACE) $(PUSH_IMAGE) node-base
./tag_and_push_multi-arch_major_minor.sh $(VERSION) $(BUILD_DATE) $(NAMESPACE) $(PUSH_IMAGE) node-docker
./tag_and_push_multi-arch_major_minor.sh $(VERSION) $(BUILD_DATE) $(NAMESPACE) $(PUSH_IMAGE) standalone-docker
./tag_and_push_multi-arch_major_minor.sh $(VERSION) $(BUILD_DATE) $(NAMESPACE) $(PUSH_IMAGE) sessions
./tag_and_push_multi-arch_major_minor.sh $(VERSION) $(BUILD_DATE) $(NAMESPACE) $(PUSH_IMAGE) session-queue
./tag_and_push_multi-arch_major_minor.sh $(VERSION) $(BUILD_DATE) $(NAMESPACE) $(PUSH_IMAGE) event-bus
./tag_and_push_multi-arch_major_minor.sh $(VERSION) $(BUILD_DATE) $(NAMESPACE) $(PUSH_IMAGE) router
./tag_and_push_multi-arch_major_minor.sh $(VERSION) $(BUILD_DATE) $(NAMESPACE) $(PUSH_IMAGE) distributor

tag_multi_arch_latest:
docker buildx imagetools create -t ${NAMESPACE}/base:latest ${NAMESPACE}/base:${TAG_VERSION}
docker buildx imagetools create -t ${NAMESPACE}/hub:latest ${NAMESPACE}/hub:${TAG_VERSION}
docker buildx imagetools create -t ${NAMESPACE}/node-base:latest ${NAMESPACE}/node-base:${TAG_VERSION}
docker buildx imagetools create -t ${NAMESPACE}/node-chromium:latest ${NAMESPACE}/node-chromium:${TAG_VERSION}
docker buildx imagetools create -t ${NAMESPACE}/node-firefox:latest ${NAMESPACE}/node-firefox:${TAG_VERSION}
docker buildx imagetools create -t ${NAMESPACE}/standalone-chromium:latest ${NAMESPACE}/standalone-chromium:${TAG_VERSION}
docker buildx imagetools create -t ${NAMESPACE}/standalone-firefox:latest ${NAMESPACE}/standalone-firefox:${TAG_VERSION}
docker buildx imagetools create -t ${NAMESPACE}/node-docker:latest ${NAMESPACE}/node-docker:${TAG_VERSION}
docker buildx imagetools create -t ${NAMESPACE}/standalone-docker:latest ${NAMESPACE}/standalone-docker:${TAG_VERSION}
docker buildx imagetools create -t ${NAMESPACE}/sessions:latest ${NAMESPACE}/sessions:${TAG_VERSION}
docker buildx imagetools create -t ${NAMESPACE}/session-queue:latest ${NAMESPACE}/session-queue:${TAG_VERSION}
docker buildx imagetools create -t ${NAMESPACE}/event-bus:latest ${NAMESPACE}/event-bus:${TAG_VERSION}
docker buildx imagetools create -t ${NAMESPACE}/router:latest ${NAMESPACE}/router:${TAG_VERSION}
docker buildx imagetools create -t ${NAMESPACE}/distributor:latest ${NAMESPACE}/distributor:${TAG_VERSION}

# ./tag-and-push-multi-arch-image.sh $(VERSION) $(BUILD_DATE) $(NAMESPACE) base latest
# ./tag-and-push-multi-arch-image.sh $(VERSION) $(BUILD_DATE) $(NAMESPACE) hub latest
# ./tag-and-push-multi-arch-image.sh $(VERSION) $(BUILD_DATE) $(NAMESPACE) node-base latest
# ./tag-and-push-multi-arch-image.sh $(VERSION) $(BUILD_DATE) $(NAMESPACE) node-chromium latest
# ./tag-and-push-multi-arch-image.sh $(VERSION) $(BUILD_DATE) $(NAMESPACE) node-firefox latest
# ./tag-and-push-multi-arch-image.sh $(VERSION) $(BUILD_DATE) $(NAMESPACE) standalone-chromium latest
# ./tag-and-push-multi-arch-image.sh $(VERSION) $(BUILD_DATE) $(NAMESPACE) standalone-firefox latest
# ./tag-and-push-multi-arch-image.sh $(VERSION) $(BUILD_DATE) $(NAMESPACE) node-docker latest
# ./tag-and-push-multi-arch-image.sh $(VERSION) $(BUILD_DATE) $(NAMESPACE) standalone-docker latest
# ./tag-and-push-multi-arch-image.sh $(VERSION) $(BUILD_DATE) $(NAMESPACE) sessions latest
# ./tag-and-push-multi-arch-image.sh $(VERSION) $(BUILD_DATE) $(NAMESPACE) session-queue latest
# ./tag-and-push-multi-arch-image.sh $(VERSION) $(BUILD_DATE) $(NAMESPACE) event-bus latest
# ./tag-and-push-multi-arch-image.sh $(VERSION) $(BUILD_DATE) $(NAMESPACE) router latest
# ./tag-and-push-multi-arch-image.sh $(VERSION) $(BUILD_DATE) $(NAMESPACE) distributor latest

release_latest:
docker push $(NAME)/base:latest
docker push $(NAME)/hub:latest
Expand Down Expand Up @@ -426,6 +550,25 @@ test_firefox:
test_firefox_standalone:
VERSION=$(TAG_VERSION) NAMESPACE=$(NAMESPACE) BINDING_VERSION=$(BINDING_VERSION) ./tests/bootstrap.sh StandaloneFirefox

# Test multi-arch container images
test_multi_arch: test_chromium_multi \
test_firefox_multi \
test_chromium_standalone_multi \
test_firefox_standalone_multi


test_chromium_multi:
VERSION=$(TAG_VERSION) NAMESPACE=$(NAMESPACE) ./tests/bootstrap.sh NodeChromium

test_chromium_standalone_multi:
VERSION=$(TAG_VERSION) NAMESPACE=$(NAMESPACE) ./tests/bootstrap.sh StandaloneChromium

test_firefox_multi:
VERSION=$(TAG_VERSION) NAMESPACE=$(NAMESPACE) ./tests/bootstrap.sh NodeFirefox

test_firefox_standalone_multi:
VERSION=$(TAG_VERSION) NAMESPACE=$(NAMESPACE) ./tests/bootstrap.sh StandaloneFirefox

test_parallel: hub chrome firefox edge
sudo rm -rf ./tests/tests
for node in DeploymentAutoscaling JobAutoscaling ; do \
Expand Down
4 changes: 2 additions & 2 deletions NodeBase/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ RUN apt-get update -qqy \
locales \
libfontconfig \
libfreetype6 \
xfonts-cyrillic \
#xfonts-cyrillic \
xfonts-scalable \
fonts-liberation \
fonts-ipafont-gothic \
fonts-wqy-zenhei \
fonts-tlwg-loma-otf \
fonts-ubuntu \
#fonts-ubuntu \
fonts-noto-color-emoji \
&& locale-gen ${LANGUAGE} \
&& dpkg-reconfigure --frontend noninteractive locales \
Expand Down
47 changes: 47 additions & 0 deletions NodeChromium/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
ARG NAMESPACE
ARG VERSION
ARG AUTHORS
FROM ${NAMESPACE}/node-base:${VERSION}
LABEL authors=${AUTHORS}

USER root

#ENV LANGUAGE=en_US.UTF-8
#ENV LC_ALL=en_US.UTF-8
#ENV LANG=en_US.UTF-8

# Deal with the usr merge issues in Debian
#RUN apt install usrmerge

# Install Chromium
# RUN echo "deb http://http.us.debian.org/debian/ stable non-free contrib main" >> /etc/apt/sources.list \
RUN echo "deb http://deb.debian.org/debian/ sid main" >> /etc/apt/sources.list \
&& apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 0E98404D386FA1D9 6ED0E7B82643E131 \
&& apt-get update -qqy \
# && apt-get -qqy install chromium=89.0.4389.82-1 \
# && apt-get -qqy install chromium=90.0.4430.212-1 \
# && apt-get -qqy install chromium=93.0.4577.82-1 \
# && apt-get -qqy install chromium=97.0.4692.71-0.1 \
# && apt-get -qqy install chromium=98.0.4758.102-1+b1 \
&& apt-get -qqy install chromium \
&& 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
RUN chromium --version | awk '{print $2}' > /opt/selenium/browser_version
RUN echo "\"goog:chromeOptions\": {\"binary\": \"/usr/bin/chromium\"}" > /opt/selenium/browser_binary_location

USER 1200

12 changes: 12 additions & 0 deletions NodeChromium/wrap_chromium_binary
Original file line number Diff line number Diff line change
@@ -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"
69 changes: 69 additions & 0 deletions NodeFirefox/Dockerfile.multi-arch
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
ARG NAMESPACE
ARG VERSION
ARG AUTHORS
FROM ${NAMESPACE}/node-base:${VERSION}
LABEL authors=${AUTHORS}

ARG TARGETARCH
ARG TARGETVARIANT

ARG GECKODRIVER_VERSION=0.34.0

USER root

# Deal with the usr merge issues in Debian
#RUN apt install usrmerge

#=========
# Firefox
#=========
#RUN echo "deb http://deb.debian.org/debian/ sid main" >> /etc/apt/sources.list \
# && apt-get update -qqy \
# && apt-get -qqy install firefox-esr libavcodec-extra \
# && apt-get -qqy install firefox libavcodec-extra \
# && rm -rf /var/lib/apt/lists/* /var/cache/apt/*

# Pulling Firefox from Debian Snapshots so we can control which version we use as latest
RUN echo "deb http://deb.debian.org/debian/ sid main" >> /etc/apt/sources.list \
&& apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 0E98404D386FA1D9 6ED0E7B82643E131 \
&& apt-get update -qqy \
&& apt-get install libavcodec-extra firefox -y \
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/*

#=============
# geckodriver
#=============
RUN if [ $TARGETARCH = "arm" ] && [ $TARGETVARIANT = "v7" ]; then \
export ARCH=armhf ; \
else \
export ARCH=$TARGETARCH ; \
fi ; \
if [ -z "$ARCH" ]; then \
echo "*** BUILD ERROR: \$TARGETARCH must be arm64, amd64, or arm with \$TARGETVARIANT set to v7... exiting..." ; \
exit 1 ; \
fi ; \
if [ "$ARCH" = "arm64" ]; then \
wget --no-verbose -O /tmp/geckodriver.tar.gz https://github.com/mozilla/geckodriver/releases/download/v$GECKODRIVER_VERSION/geckodriver-v$GECKODRIVER_VERSION-linux-aarch64.tar.gz ; \
elif [ "$ARCH" = "armhf" ]; then \
wget --no-verbose -O /tmp/geckodriver.tar.gz https://github.com/jamesmortensen/geckodriver-arm-binaries/releases/download/v$GECKODRIVER_VERSION/geckodriver-v$GECKODRIVER_VERSION-linux-armv7l.tar.gz ; \
else \
wget --no-verbose -O /tmp/geckodriver.tar.gz https://github.com/mozilla/geckodriver/releases/download/v$GECKODRIVER_VERSION/geckodriver-v$GECKODRIVER_VERSION-linux64.tar.gz ; \
fi ; \
tar -C /tmp -zxf /tmp/geckodriver.tar.gz ; \
rm /tmp/geckodriver.tar.gz ; \
mkdir -p /opt/geckodriver-bin ; \
mv /tmp/geckodriver /opt/geckodriver-bin/geckodriver ; \
echo "Symlinking geckodriver to /usr/local/bin/geckodriver and /usr/bin/geckodriver" ; \
ln -s /opt/geckodriver-bin/geckodriver /usr/local/bin/geckodriver ; \
chmod 755 /usr/local/bin/geckodriver ; \
ln -s /opt/geckodriver-bin/geckodriver /usr/bin/geckodriver ; \
chmod 755 /usr/bin/geckodriver

USER 1200

#============================================
# Dumping Browser name and version for config
#============================================
RUN echo "firefox" > /opt/selenium/browser_name
RUN firefox --version | awk '{print $3}' > /opt/selenium/browser_version
RUN echo "\"moz:firefoxOptions\": {\"binary\": \"/usr/bin/firefox\"}" > /opt/selenium/browser_binary_location
Loading

0 comments on commit 2b2e490

Please sign in to comment.