Skip to content

Commit 2cad63b

Browse files
authored
Docker: Support switch binary Chrome/Chromium in Node/Standalone all browsers image (#2946)
* Docker: Support switch binary Chrome/Chromium in Node/Standalone all browsers image * Reduce CVEs in package --------- Signed-off-by: Viet Nguyen Duc <[email protected]>
1 parent abae4b7 commit 2cad63b

File tree

9 files changed

+58
-34
lines changed

9 files changed

+58
-34
lines changed

Base/Dockerfile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ LABEL org.opencontainers.image.source="https://github.com/${AUTHORS}/docker-sele
77
ARG VERSION
88
ARG RELEASE=selenium-${VERSION}
99
# Default value should be aligned with upstream Selenium (https://github.com/SeleniumHQ/selenium/blob/trunk/MODULE.bazel)
10-
ARG OPENTELEMETRY_VERSION=1.51.0
11-
ARG GRPC_VERSION=1.73.0
12-
ARG NETTY_VERSION=4.1.123.Final
13-
ARG CS_VERSION=2.1.24
10+
ARG OPENTELEMETRY_VERSION=1.53.0
11+
ARG GRPC_VERSION=1.74.0
12+
ARG NETTY_VERSION=4.1.126.Final
13+
ARG CS_VERSION=2.1.25-M18
1414
ARG ENVSUBST_VERSION=1.4.5
1515
ARG CURL_VERSION=8.15.0
1616

@@ -144,8 +144,8 @@ RUN --mount=type=secret,id=SEL_PASSWD \
144144
io.opentelemetry:opentelemetry-exporter-otlp:${OPENTELEMETRY_VERSION} \
145145
io.grpc:grpc-netty:${GRPC_VERSION} \
146146
io.netty:netty-codec-http:${NETTY_VERSION} \
147-
io.netty:netty-handler:${NETTY_VERSION} \
148-
io.netty:netty-common:${NETTY_VERSION} \
147+
io.netty:netty-codec-http2:${NETTY_VERSION} \
148+
io.netty:netty-codec:${NETTY_VERSION} \
149149
> /external_jars/.classpath.txt \
150150
&& chmod 664 /external_jars/.classpath.txt ; \
151151
fi \

ENV_VARIABLES.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,18 +110,18 @@
110110
| SE_NODE_MAX_SESSIONS | 1 | | |
111111
| SE_NODE_OVERRIDE_MAX_SESSIONS | false | | |
112112
| SE_OFFLINE | true | Selenium Manager offline mode, use the browser and driver pre-configured in the image | |
113-
| SE_NODE_BROWSER_VERSION | stable | Overwrite the default browserVersion in Node stereotype | |
114-
| SE_NODE_PLATFORM_NAME | Linux | Overwrite the default platformName in Node stereotype | |
113+
| SE_NODE_BROWSER_VERSION | stable | Overwrite the default browserVersion in Node stereotype. By default, it is short version of current browser installed in Node. For example `139.0` | |
114+
| SE_NODE_PLATFORM_NAME | Linux | Overwrite the default platformName in Node stereotype. By default, it is `Linux` | |
115115
| SE_SUPERVISORD_LOG_LEVEL | info | | |
116116
| SE_SUPERVISORD_CHILD_LOG_DIR | /tmp | | |
117117
| SE_SUPERVISORD_LOG_FILE | /tmp/supervisord.log | | |
118118
| SE_SUPERVISORD_AUTO_RESTART | true | | |
119119
| SE_SUPERVISORD_START_RETRIES | 5 | | |
120120
| SE_RECORD_AUDIO | false | Flag to enable recording the audio source (default is Pulse Audio input) | |
121121
| SE_AUDIO_SOURCE | -f pulse -ac 2 -i default | FFmpeg arguments to record the audio source | |
122-
| SE_BROWSER_BINARY_LOCATION | | | |
122+
| SE_BROWSER_BINARY_LOCATION | | Browser binary location set to Node driver configuration. This helpful in case you customize on top of official Docker image to install another browser in other path and still using GENERATE_CONFIG=true (where enforce detect-drivers = false and controlled by our config logic). By default in corresponding browser, default path would be `/usr/bin/google-chrome`, `/usr/bin/chromium`, `/usr/bin/firefox`, `/usr/bin/microsoft-edge`. Example usage: `SE_BROWSER_BINARY_LOCATION=/opt/google-chrome` | |
123123
| SE_NODE_BROWSER_NAME | | | |
124-
| SE_NODE_CONTAINER_NAME | | | |
124+
| SE_NODE_CONTAINER_NAME | | Set a unique name to identify the Node is running in which container (via session capabilities `se:containerName`). This is helpful when deploying Node in Kubernetes cluster, where is able to use metadata pod name set to this env variable. By default, it is the `$(hostname)` (a.k.a container id could be seen via `docker ps`) | |
125125
| SE_NODE_HOST | | | |
126126
| SE_NODE_RELAY_BROWSER_NAME | | | |
127127
| SE_NODE_RELAY_MAX_SESSIONS | | | |
@@ -131,7 +131,7 @@
131131
| SE_NODE_RELAY_STATUS_ENDPOINT | | | |
132132
| SE_NODE_RELAY_URL | | | |
133133
| SE_NODE_STEREOTYPE | | Capabilities in JSON string to overwrite the default Node stereotype | |
134-
| SE_NODE_STEREOTYPE_EXTRA | | Extra capabilities in JSON string that wants to merge to the default Node stereotype | |
134+
| SE_NODE_STEREOTYPE_EXTRA | | Extra capabilities in JSON string that wants to merge to the default Node stereotype. This is helpful when you want to retain the default Node stereotype and append additional capabilities. Example usage `SE_NODE_STEREOTYPE_EXTRA={"myApp:version":"beta","myApp:publish":"public"}` | |
135135
| SE_SESSIONS_MAP_EXTERNAL_HOSTNAME | | | |
136136
| SE_SESSIONS_MAP_EXTERNAL_IMPLEMENTATION | | | |
137137
| SE_SESSIONS_MAP_EXTERNAL_JDBC_PASSWORD | | | |

NodeBase/generate_config

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,16 +144,17 @@ if [ -d "/opt/selenium/browsers" ]; then
144144
if [ -f "${browser_dir}version" ] && [ "${SE_NODE_BROWSER_VERSION,,}" = "stable" ]; then
145145
SE_NODE_BROWSER_VERSION=$(short_version "$(cat "${browser_dir}version")")
146146
fi
147-
if [ -f "${browser_dir}binary_location" ] && [ -z "${SE_BROWSER_BINARY_LOCATION}" ]; then
148-
SE_BROWSER_BINARY_LOCATION=$(cat "${browser_dir}binary_location")
147+
if [ -f "${browser_dir}binary_location" ]; then
148+
BINARY_LOCATION=$(cat "${browser_dir}binary_location")
149+
BINARY_LOCATION=$(echo "$BINARY_LOCATION" | SE_BROWSER_BINARY_LOCATION=${SE_BROWSER_BINARY_LOCATION} envsubst)
149150
fi
150151
SE_NODE_CONTAINER_NAME="${SE_NODE_CONTAINER_NAME:-$(hostname)}"
151152

152153
# 'browserName' is mandatory for default stereotype
153154
if [[ -z "${SE_NODE_STEREOTYPE}" ]] && [[ -n "${SE_NODE_BROWSER_NAME}" ]] && ([[ -z "${SE_NODE_RELAY_URL}" ]] || [[ "${SE_NODE_RELAY_ONLY}" = "false" ]]); then
154155
SE_NODE_STEREOTYPE="{\"browserName\": \"${SE_NODE_BROWSER_NAME}\", \"browserVersion\": \"${SE_NODE_BROWSER_VERSION}\", \"platformName\": \"${SE_NODE_PLATFORM_NAME}\", \"se:containerName\": \"${SE_NODE_CONTAINER_NAME}\", \"container:hostname\": \"$(hostname)\"}"
155-
if [[ -n "${SE_BROWSER_BINARY_LOCATION}" ]]; then
156-
SE_NODE_STEREOTYPE="$(python3 /opt/bin/json_merge.py "${SE_NODE_STEREOTYPE}" "${SE_BROWSER_BINARY_LOCATION}")"
156+
if [[ -n "${BINARY_LOCATION}" ]]; then
157+
SE_NODE_STEREOTYPE="$(python3 /opt/bin/json_merge.py "${SE_NODE_STEREOTYPE}" "${BINARY_LOCATION}")"
157158
fi
158159
else
159160
SE_NODE_STEREOTYPE="${SE_NODE_STEREOTYPE}"

NodeChrome/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ USER ${SEL_UID}
5252
RUN mkdir -p /opt/selenium/browsers/chrome \
5353
&& echo "chrome" > /opt/selenium/browsers/chrome/name \
5454
&& google-chrome --version | awk '{print $3}' > /opt/selenium/browsers/chrome/version \
55-
&& echo '{"goog:chromeOptions": {"binary": "/usr/bin/google-chrome"}}' > /opt/selenium/browsers/chrome/binary_location
55+
&& echo '{"goog:chromeOptions": {"binary": "${SE_BROWSER_BINARY_LOCATION:-/usr/bin/google-chrome}"}}' > /opt/selenium/browsers/chrome/binary_location
5656

5757
ENV SE_OTEL_SERVICE_NAME="selenium-node-chrome" \
5858
SE_NODE_ENABLE_MANAGED_DOWNLOADS="true"

NodeChromium/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ USER ${SEL_UID}
4646
RUN mkdir -p /opt/selenium/browsers/chrome \
4747
&& echo "chrome" > /opt/selenium/browsers/chrome/name \
4848
&& chromium --version | awk '{print $2}' > /opt/selenium/browsers/chrome/version \
49-
&& echo '{"goog:chromeOptions": {"binary": "/usr/bin/chromium"}}' > /opt/selenium/browsers/chrome/binary_location
49+
&& echo '{"goog:chromeOptions": {"binary": "${SE_BROWSER_BINARY_LOCATION:-/usr/bin/chromium}"}}' > /opt/selenium/browsers/chrome/binary_location
5050

5151
ENV SE_OTEL_SERVICE_NAME="selenium-node-chrome" \
5252
SE_NODE_ENABLE_MANAGED_DOWNLOADS="true"

NodeEdge/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ USER ${SEL_UID}
6969
RUN mkdir -p /opt/selenium/browsers/edge \
7070
&& echo "MicrosoftEdge" > /opt/selenium/browsers/edge/name \
7171
&& microsoft-edge --version | awk '{print $3}' > /opt/selenium/browsers/edge/version \
72-
&& echo '{"ms:edgeOptions": {"binary": "/usr/bin/microsoft-edge"}}' > /opt/selenium/browsers/edge/binary_location
72+
&& echo '{"ms:edgeOptions": {"binary": "${SE_BROWSER_BINARY_LOCATION:-/usr/bin/microsoft-edge}"}}' > /opt/selenium/browsers/edge/binary_location
7373

7474
ENV SE_OTEL_SERVICE_NAME="selenium-node-edge" \
7575
SE_NODE_ENABLE_MANAGED_DOWNLOADS="true"

NodeFirefox/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ USER ${SEL_UID}
8888
RUN mkdir -p /opt/selenium/browsers/firefox \
8989
&& echo "firefox" > /opt/selenium/browsers/firefox/name \
9090
&& firefox --version | awk '{print $3}' > /opt/selenium/browsers/firefox/version \
91-
&& echo '{"moz:firefoxOptions": {"binary": "/usr/bin/firefox"}}' > /opt/selenium/browsers/firefox/binary_location
91+
&& echo '{"moz:firefoxOptions": {"binary": "${SE_BROWSER_BINARY_LOCATION:-/usr/bin/firefox}"}}' > /opt/selenium/browsers/firefox/binary_location
9292

9393
ENV SE_OTEL_SERVICE_NAME="selenium-node-firefox" \
9494
SE_NODE_ENABLE_MANAGED_DOWNLOADS="true"

README.md

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ Talk to us at https://www.selenium.dev/support/
4747
* [Dev and Beta Channel Browser Images](#dev-and-beta-channel-browser-images)
4848
* [Dev and Beta Standalone Mode](#dev-and-beta-standalone-mode)
4949
* [Dev and Beta on the Grid](#dev-and-beta-on-the-grid)
50+
* [Single Node/Standalone Image With All Browsers](#single-nodestandalone-image-with-all-browsers)
5051
* [Environment Variables](#environment-variables)
5152
* [Execution modes](#execution-modes)
5253
* [Standalone](#standalone)
@@ -160,16 +161,6 @@ The following browsers are available in multi-arch images:
160161
| aarch64 (aka arm64/armv8) |||||
161162
| armhf (aka arm32/armv7l) |||||
162163

163-
164-
Accordingly, browsers are available in images `selenium/node-all-browsers` and `selenium/standalone-all-browsers` would be different per architecture.
165-
166-
| Browser / Arch | x86_64 (aka amd64) | aarch64 (aka arm64/armv8) |
167-
|----------------|--------------------|---------------------------|
168-
| Chrome |||
169-
| Edge |||
170-
| Firefox |||
171-
| Chromium |||
172-
173164
Note:
174165

175166
- **Running an AMD64 image under emulation on an ARM64 platform is not recommended due to performance and [stability issues](https://github.com/SeleniumHQ/docker-selenium/issues/2298), or browsers could not launch.**
@@ -374,6 +365,26 @@ services:
374365

375366
For more information on the Dev and Beta channel container images, see the blog post on [Dev and Beta Channel Browsers via Docker Selenium](https://www.selenium.dev/blog/2022/dev-and-beta-channel-browsers-via-docker-selenium/).
376367

368+
## Single Node/Standalone Image With All Browsers
369+
370+
From image tag `4.35.0` onwards, a single Node/Standalone image is available with all browsers are pre-installed. Those images are `selenium/standalone-all-browsers` (standalone all in one), `selenium/node-all-browsers` (for Hub-Node mode).
371+
372+
These two images are suitable for users:
373+
- Prefer a single container with "all-in-one" includes Selenium Grid and popular browsers.
374+
- Don't care about the image size, prefer the convenience.
375+
- Lightweight workload, able to figure out for yourself the resource consumption.
376+
377+
According to multi-arch support, browsers are available in images `selenium/node-all-browsers` and `selenium/standalone-all-browsers` would be different per architecture.
378+
379+
| Browser / Arch | x86_64 (aka amd64) | aarch64 (aka arm64/armv8) |
380+
|----------------|--------------------|---------------------------|
381+
| Chrome |||
382+
| Edge |||
383+
| Firefox |||
384+
| Chromium |||
385+
386+
Both Chrome and Chromium browser binary are available in image arch `linux/amd64`. However, Chrome browser binary is activated by default. In case you want to switch to Chromium browser binary, you can set environment variable `SE_BROWSER_BINARY_LOCATION_CHROME=/usr/bin/chromium`.
387+
377388
## Environment Variables
378389

379390
**Checkout full list of environment variables [here](ENV_VARIABLES.md).**

scripts/generate_list_env_vars/description.yaml

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -339,10 +339,12 @@
339339
in the image
340340
cli: ''
341341
- name: SE_NODE_BROWSER_VERSION
342-
description: Overwrite the default browserVersion in Node stereotype
342+
description: Overwrite the default browserVersion in Node stereotype. By default,
343+
it is short version of current browser installed in Node. For example `139.0`
343344
cli: ''
344345
- name: SE_NODE_PLATFORM_NAME
345-
description: Overwrite the default platformName in Node stereotype
346+
description: Overwrite the default platformName in Node stereotype. By default,
347+
it is `Linux`
346348
cli: ''
347349
- name: SE_SUPERVISORD_LOG_LEVEL
348350
description: ''
@@ -366,13 +368,22 @@
366368
description: FFmpeg arguments to record the audio source
367369
cli: ''
368370
- name: SE_BROWSER_BINARY_LOCATION
369-
description: ''
371+
description: 'Browser binary location set to Node driver configuration. This helpful
372+
in case you customize on top of official Docker image to install another browser
373+
in other path and still using GENERATE_CONFIG=true (where enforce detect-drivers
374+
= false and controlled by our config logic). By default in corresponding browser,
375+
default path would be `/usr/bin/google-chrome`, `/usr/bin/chromium`, `/usr/bin/firefox`,
376+
`/usr/bin/microsoft-edge`. Example usage: `SE_BROWSER_BINARY_LOCATION=/opt/google-chrome`'
370377
cli: ''
371378
- name: SE_NODE_BROWSER_NAME
372379
description: ''
373380
cli: ''
374381
- name: SE_NODE_CONTAINER_NAME
375-
description: ''
382+
description: Set a unique name to identify the Node is running in which container
383+
(via session capabilities `se:containerName`). This is helpful when deploying
384+
Node in Kubernetes cluster, where is able to use metadata pod name set to this
385+
env variable. By default, it is the `$(hostname)` (a.k.a container id could be
386+
seen via `docker ps`)
376387
cli: ''
377388
- name: SE_NODE_HOST
378389
description: ''
@@ -403,7 +414,8 @@
403414
cli: ''
404415
- name: SE_NODE_STEREOTYPE_EXTRA
405416
description: Extra capabilities in JSON string that wants to merge to the default
406-
Node stereotype
417+
Node stereotype. This is helpful when you want to retain the default Node stereotype
418+
and append additional capabilities. Example usage `SE_NODE_STEREOTYPE_EXTRA={"myApp:version":"beta","myApp:publish":"public"}`
407419
cli: ''
408420
- name: SE_SESSIONS_MAP_EXTERNAL_HOSTNAME
409421
description: ''

0 commit comments

Comments
 (0)