Skip to content

Commit 3c74143

Browse files
authored
Refactoring env vars to add SE_ prefix (#1603)
In preparation for #1319, which makes it easier to collect the environment variables that matter to configure child containers.
1 parent 5d143a8 commit 3c74143

20 files changed

+107
-55
lines changed

Distributor/start-selenium-grid-distributor.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ if [ ! -z "$SE_DISTRIBUTOR_PORT" ]; then
5555
fi
5656

5757

58-
java ${JAVA_OPTS} -jar /opt/selenium/selenium-server.jar distributor \
58+
java ${JAVA_OPTS:-$SE_JAVA_OPTS} -jar /opt/selenium/selenium-server.jar distributor \
5959
--sessions-host "${SE_SESSIONS_MAP_HOST}" --sessions-port "${SE_SESSIONS_MAP_PORT}" \
6060
--sessionqueue-host "${SE_SESSION_QUEUE_HOST}" --sessionqueue-port "${SE_SESSION_QUEUE_PORT}" \
6161
--publish-events tcp://"${SE_EVENT_BUS_HOST}":"${SE_EVENT_BUS_PUBLISH_PORT}" \

EventBus/start-selenium-grid-eventbus.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ if [ ! -z "$SE_OPTS" ]; then
1919
echo "Appending Selenium options: ${SE_OPTS}"
2020
fi
2121

22-
java ${JAVA_OPTS} -jar /opt/selenium/selenium-server.jar event-bus \
22+
java ${JAVA_OPTS:-$SE_JAVA_OPTS} -jar /opt/selenium/selenium-server.jar event-bus \
2323
--bind-host ${SE_BIND_HOST} \
2424
${HOST_CONFIG} \
2525
${PORT_CONFIG} \

Hub/start-selenium-grid-hub.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ if [ ! -z "$SE_HUB_PORT" ]; then
1818
fi
1919

2020

21-
java ${JAVA_OPTS} -jar /opt/selenium/selenium-server.jar hub \
21+
java ${JAVA_OPTS:-$SE_JAVA_OPTS} -jar /opt/selenium/selenium-server.jar hub \
2222
--session-request-timeout ${SE_SESSION_REQUEST_TIMEOUT} \
2323
--session-retry-interval ${SE_SESSION_RETRY_INTERVAL} \
2424
--relax-checks ${SE_RELAX_CHECKS} \

NodeBase/Dockerfile.txt

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -154,20 +154,24 @@ COPY selenium_grid_logo.png /usr/share/images/fluxbox/ubuntu-light.png
154154
#============================
155155
# Some configuration options
156156
#============================
157-
ENV SCREEN_WIDTH 1360
158-
ENV SCREEN_HEIGHT 1020
159-
ENV SCREEN_DEPTH 24
160-
ENV SCREEN_DPI 96
157+
ENV SE_SCREEN_WIDTH 1360
158+
ENV SE_SCREEN_HEIGHT 1020
159+
ENV SE_SCREEN_DEPTH 24
160+
ENV SE_SCREEN_DPI 96
161+
ENV SE_START_XVFB true
162+
ENV SE_START_NO_VNC true
163+
ENV SE_NO_VNC_PORT 7900
164+
ENV SE_VNC_PORT 5900
161165
ENV DISPLAY :99.0
162166
ENV DISPLAY_NUM 99
163-
ENV START_XVFB true
164-
ENV START_NO_VNC true
165167
# Path to the Configfile
166168
ENV CONFIG_FILE=/opt/selenium/config.toml
167169
ENV GENERATE_CONFIG true
168170
# Drain the Node after N sessions.
169171
# A value higher than zero enables the feature
170-
ENV DRAIN_AFTER_SESSION_COUNT 0
172+
ENV SE_DRAIN_AFTER_SESSION_COUNT 0
173+
174+
171175

172176
#========================
173177
# Selenium Configuration

NodeBase/generate_config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ fi
4646
echo "session-timeout = \"${SE_NODE_SESSION_TIMEOUT}\"" >> "$FILENAME"
4747
echo "override-max-sessions = ${SE_NODE_OVERRIDE_MAX_SESSIONS}" >> "$FILENAME"
4848
echo "detect-drivers = false" >> "$FILENAME"
49-
echo "drain-after-session-count = ${DRAIN_AFTER_SESSION_COUNT}" >> "$FILENAME"
49+
echo "drain-after-session-count = ${DRAIN_AFTER_SESSION_COUNT:-$SE_DRAIN_AFTER_SESSION_COUNT}" >> "$FILENAME"
5050
echo "max-sessions = ${SE_NODE_MAX_SESSIONS}
5151
" >> "$FILENAME"
5252

NodeBase/start-novnc.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
#
33
# IMPORTANT: Change this file only in directory NodeBase!
44

5-
if [ "${START_XVFB}" = true ] ; then
6-
if [ "${START_NO_VNC}" = true ] ; then
7-
/opt/bin/noVNC/utils/launch.sh --listen ${NO_VNC_PORT:-7900} --vnc localhost:${VNC_PORT:-5900}
5+
if [ "${START_XVFB:-$SE_START_XVFB}" = true ] ; then
6+
if [ "${START_NO_VNC:-$SE_START_NO_VNC}" = true ] ; then
7+
/opt/bin/noVNC/utils/launch.sh --listen ${NO_VNC_PORT:-$SE_NO_VNC_PORT} --vnc localhost:${VNC_PORT:-$SE_VNC_PORT}
88
else
9-
echo "noVNC won't start because START_NO_VNC is false."
9+
echo "noVNC won't start because SE_START_NO_VNC is false."
1010
fi
1111
else
1212
echo "noVNC won't start because Xvfb is configured to not start."

NodeBase/start-selenium-node.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ fi
3838
echo "Selenium Grid Node configuration: "
3939
cat "$CONFIG_FILE"
4040
echo "Starting Selenium Grid Node..."
41-
java ${JAVA_OPTS} -jar /opt/selenium/selenium-server.jar node \
41+
java ${JAVA_OPTS:-$SE_JAVA_OPTS} -jar /opt/selenium/selenium-server.jar node \
4242
--bind-host ${SE_BIND_HOST} \
4343
--config "$CONFIG_FILE" \
4444
${SE_OPTS}

NodeBase/start-vnc.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# IMPORTANT: Change this file only in directory NodeBase!
44

5-
if [ "${START_XVFB}" = true ] ; then
5+
if [ "${START_XVFB:-$SE_START_XVFB}" = true ] ; then
66
# Centering wallpaper
77
for i in $(seq 1 10)
88
do
@@ -14,13 +14,15 @@ if [ "${START_XVFB}" = true ] ; then
1414
fi
1515
done
1616

17+
VNC_NO_PASSWORD=${VNC_NO_PASSWORD:-$SE_VNC_NO_PASSWORD}
1718
if [ ! -z $VNC_NO_PASSWORD ]; then
1819
echo "Starting VNC server without password authentication"
1920
X11VNC_OPTS=
2021
else
2122
X11VNC_OPTS=-usepw
2223
fi
2324

25+
VNC_VIEW_ONLY=${VNC_VIEW_ONLY:-$SE_VNC_VIEW_ONLY}
2426
if [ ! -z $VNC_VIEW_ONLY ]; then
2527
echo "Starting VNC server with viewonly option"
2628
X11VNC_OPTS="${X11VNC_OPTS} -viewonly"
@@ -36,7 +38,7 @@ if [ "${START_XVFB}" = true ] ; then
3638
echo "Waiting for Xvfb..."
3739
done
3840

39-
x11vnc ${X11VNC_OPTS} -forever -shared -rfbport ${VNC_PORT:-5900} -rfbportv6 ${VNC_PORT:-5900} -display ${DISPLAY}
41+
x11vnc ${X11VNC_OPTS} -forever -shared -rfbport ${VNC_PORT:-$SE_VNC_PORT} -rfbportv6 ${VNC_PORT:-$SE_VNC_PORT} -display ${DISPLAY}
4042
else
4143
echo "Vnc won't start because Xvfb is configured to not start."
4244
fi

NodeBase/start-xvfb.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
#!/usr/bin/env bash
22

3-
if [ "${START_XVFB}" = true ] ; then
3+
SCREEN_WIDTH=${SCREEN_WIDTH:-$SE_SCREEN_WIDTH}
4+
SCREEN_HEIGHT=${SCREEN_HEIGHT:-$SE_SCREEN_HEIGHT}
5+
SCREEN_DEPTH=${SCREEN_DEPTH:-$SE_SCREEN_DEPTH}
6+
SCREEN_DPI=${SCREEN_DPI:-$SE_SCREEN_DPI}
7+
8+
if [ "${START_XVFB:-$SE_START_XVFB}" = true ] ; then
49
export GEOMETRY="${SCREEN_WIDTH}""x""${SCREEN_HEIGHT}""x""${SCREEN_DEPTH}"
510

611
rm -f /tmp/.X*lock

NodeDocker/start-selenium-grid-docker.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ if [ ! -z "$SE_NODE_GRID_URL" ]; then
2929
SE_GRID_URL="--grid-url ${SE_NODE_GRID_URL}"
3030
fi
3131

32-
java ${JAVA_OPTS} -jar /opt/selenium/selenium-server.jar node \
32+
java ${JAVA_OPTS:-$SE_JAVA_OPTS} -jar /opt/selenium/selenium-server.jar node \
3333
--publish-events tcp://"${SE_EVENT_BUS_HOST}":${SE_EVENT_BUS_PUBLISH_PORT} \
3434
--subscribe-events tcp://"${SE_EVENT_BUS_HOST}":${SE_EVENT_BUS_SUBSCRIBE_PORT} \
3535
--bind-host ${SE_BIND_HOST} \

README.md

Lines changed: 47 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Talk to us at https://www.selenium.dev/support/
4040
* [Kubernetes](#deploying-to-kubernetes)
4141
* [Configuring the containers](#configuring-the-containers)
4242
+ [SE_OPTS Selenium Configuration Options](#se_opts-selenium-configuration-options)
43-
+ [JAVA_OPTS Java Environment Options](#java_opts-java-environment-options)
43+
+ [SE_JAVA_OPTS Java Environment Options](#se_java_opts-java-environment-options)
4444
+ [Node configuration options](#node-configuration-options)
4545
+ [Setting Screen Resolution](#setting-screen-resolution)
4646
+ [Grid Url and Session Timeout](#grid-url-and-session-timeout)
@@ -550,6 +550,38 @@ Here is an example using a Hub and a Node:
550550
[`docker-compose-v3-dynamic-grid.yml`](docker-compose-v3-dynamic-grid.yml)
551551

552552

553+
### Configuring the child containers
554+
555+
Containers can be further configured through environment variables, such as `SE_NODE_SESSION_TIMEOUT`
556+
and `SE_OPTS`. When a child container is created, all environment variables prefixed with `SE_` will
557+
be forwared and set in the container. You can set the desired environment variables in the
558+
`standalone-docker` or `node-docker` containers. The following example sets the session timeout to
559+
700 seconds for all sessions:
560+
561+
#### macOS/Linux
562+
563+
```bash
564+
docker run --rm --name selenium-docker -p 4444:4444 \
565+
-e SE_NODE_SESSION_TIMEOUT=700 \
566+
-v ${PWD}/config.toml:/opt/bin/config.toml \
567+
-v ${PWD}/assets:/opt/selenium/assets \
568+
-v /var/run/docker.sock:/var/run/docker.sock \
569+
selenium/standalone-docker:4.2.2-20220609
570+
```
571+
572+
#### Windows PowerShell
573+
574+
```bash
575+
docker run --rm --name selenium-docker -p 4444:4444 `
576+
-e SE_NODE_SESSION_TIMEOUT=700 `
577+
-v ${PWD}/config.toml:/opt/bin/config.toml `
578+
-v ${PWD}/assets:/opt/selenium/assets `
579+
-v /var/run/docker.sock:/var/run/docker.sock `
580+
selenium/standalone-docker:4.2.2-20220609
581+
```
582+
583+
584+
553585
### Video recording, screen resolution, and time zones in a Dynamic Grid
554586
To record your WebDriver session, you need to add a `se:recordVideo`
555587
field set to `true`. You can also set a time zone and a screen resolution,
@@ -586,12 +618,12 @@ You can pass `SE_OPTS` variable with additional commandline parameters for start
586618
$ docker run -d -p 4444:4444 -e SE_OPTS="--log-level FINE" --name selenium-hub selenium/hub:4.2.2-20220609
587619
```
588620

589-
### JAVA_OPTS Java Environment Options
621+
### SE_JAVA_OPTS Java Environment Options
590622

591-
You can pass `JAVA_OPTS` environment variable to java process.
623+
You can pass `SE_JAVA_OPTS` environment variable to java process.
592624

593625
``` bash
594-
$ docker run -d -p 4444:4444 -e JAVA_OPTS=-Xmx512m --name selenium-hub selenium/hub:4.2.2-20220609
626+
$ docker run -d -p 4444:4444 -e SE_JAVA_OPTS=-Xmx512m --name selenium-hub selenium/hub:4.2.2-20220609
595627
```
596628

597629
### Node configuration options
@@ -614,11 +646,11 @@ $ docker run -d -e SE_EVENT_BUS_HOST=<event_bus_ip|event_bus_name> -e SE_EVENT_B
614646
### Setting Screen Resolution
615647

616648
By default, nodes start with a screen resolution of 1360 x 1020 with a color depth of 24 bits and a dpi of 96.
617-
These settings can be adjusted by specifying `SCREEN_WIDTH`, `SCREEN_HEIGHT`, `SCREEN_DEPTH`, and/or `SCREEN_DPI`
649+
These settings can be adjusted by specifying `SE_SCREEN_WIDTH`, `SE_SCREEN_HEIGHT`, `SE_SCREEN_DEPTH`, and/or `SE_SCREEN_DPI`
618650
environmental variables when starting the container.
619651

620652
``` bash
621-
docker run -d -e SCREEN_WIDTH=1366 -e SCREEN_HEIGHT=768 -e SCREEN_DEPTH=24 -e SCREEN_DPI=74 selenium/standalone-firefox:4.2.2-20220609
653+
docker run -d -e SE_SCREEN_WIDTH=1366 -e SE_SCREEN_HEIGHT=768 -e SE_SCREEN_DEPTH=24 -e SE_SCREEN_DPI=74 selenium/standalone-firefox:4.2.2-20220609
622654
```
623655

624656
### Grid Url and Session Timeout
@@ -663,12 +695,12 @@ captured in the same video.
663695
[Chrome](https://developers.google.com/web/updates/2017/04/headless-chrome),
664696
When using headless mode, there's no need for the [Xvfb](https://en.wikipedia.org/wiki/Xvfb) server to be started.
665697

666-
To avoid starting the server you can set the `START_XVFB` environment variable to `false`
698+
To avoid starting the server you can set the `SE_START_XVFB` environment variable to `false`
667699
(or any other value than `true`), for example:
668700

669701
``` bash
670702
$ docker run -d --net grid -e SE_EVENT_BUS_HOST=selenium-hub -e SE_EVENT_BUS_PUBLISH_PORT=4442 \
671-
-e SE_EVENT_BUS_SUBSCRIBE_PORT=4443 -e START_XVFB=false --shm-size="2g" selenium/node-chrome:4.2.2-20220609
703+
-e SE_EVENT_BUS_SUBSCRIBE_PORT=4443 -e SE_START_XVFB=false --shm-size="2g" selenium/node-chrome:4.2.2-20220609
672704
```
673705

674706
For more information, see this GitHub [issue](https://github.com/SeleniumHQ/docker-selenium/issues/567).
@@ -677,11 +709,11 @@ For more information, see this GitHub [issue](https://github.com/SeleniumHQ/dock
677709

678710
In some environments, like Docker Swarm or Kubernetes, it is useful to shut down the Node or Standalone
679711
container after N tests have been executed. For example, this can be used in Kubernetes to terminate the
680-
pod and then scale a new one after N sessions. Set the environment variable `DRAIN_AFTER_SESSION_COUNT` to
712+
pod and then scale a new one after N sessions. Set the environment variable `SE_DRAIN_AFTER_SESSION_COUNT` to
681713
a value higher than zero to enable this behaviour.
682714

683715
``` bash
684-
$ docker run -e DRAIN_AFTER_SESSION_COUNT=5 --shm-size="2g" selenium/standalone-firefox:4.2.2-20220609
716+
$ docker run -e SE_DRAIN_AFTER_SESSION_COUNT=5 --shm-size="2g" selenium/standalone-firefox:4.2.2-20220609
685717
```
686718

687719
With the previous command, the Standalone container will shutdown after 5 sessions have been executed.
@@ -883,7 +915,7 @@ The VNC server is listening to port 5900, you can use a VNC client and connect t
883915
any free external port that you wish.
884916

885917
The internal 5900 port remains the same because that is the configured port for the VNC server running inside the container.
886-
You can override it with the `VNC_PORT` environment variable in case you want to use `--net=host`.
918+
You can override it with the `SE_VNC_PORT` environment variable in case you want to use `--net=host`.
887919

888920
Here is an example with the standalone images, the same concept applies to the node images.
889921
``` bash
@@ -910,9 +942,9 @@ the posted ones which reconfigures it:
910942
RUN x11vnc -storepasswd <your-password-here> /home/seluser/.vnc/passwd
911943
```
912944

913-
If you want to run VNC without password authentication you can set the environment variable `VNC_NO_PASSWORD=1`.
945+
If you want to run VNC without password authentication you can set the environment variable `SE_VNC_NO_PASSWORD=1`.
914946

915-
If you want to run VNC in view-only mode you can set the environment variable `VNC_VIEW_ONLY=1`.
947+
If you want to run VNC in view-only mode you can set the environment variable `SE_VNC_VIEW_ONLY=1`.
916948

917949
### Using your browser (no VNC client is needed)
918950

@@ -921,7 +953,7 @@ their browser. This might come handy if you cannot install a VNC client on your
921953
noVNC, so you will need to connect to that port with your browser.
922954

923955
Similarly to the previous section, feel free to map port 7900 to any free external port that you wish.
924-
You can also override it with the `NO_VNC_PORT` environment variable in case you want to use `--net=host`.
956+
You can also override it with the `SE_NO_VNC_PORT` environment variable in case you want to use `--net=host`.
925957

926958
Here is an example with the standalone images, the same concept applies to the node images.
927959
``` bash
@@ -970,7 +1002,7 @@ or
9701002

9711003
`Message: unknown error: Chrome failed to start: exited abnormally`
9721004

973-
The reason _might_ be that you've set the `START_XVFB` environment variable to "false", but forgot to
1005+
The reason _might_ be that you've set the `SE_START_XVFB` environment variable to "false", but forgot to
9741006
actually run Firefox, Chrome or Edge in headless mode.
9751007

9761008
### Mounting volumes to retrieve downloaded files

Router/start-selenium-grid-router.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ if [ ! -z "$SE_ROUTER_PORT" ]; then
4949
PORT_CONFIG="--port ${SE_ROUTER_PORT}"
5050
fi
5151

52-
java ${JAVA_OPTS} -jar /opt/selenium/selenium-server.jar router \
52+
java ${JAVA_OPTS:-$SE_JAVA_OPTS} -jar /opt/selenium/selenium-server.jar router \
5353
--sessions-host "${SE_SESSIONS_MAP_HOST}" --sessions-port "${SE_SESSIONS_MAP_PORT}" \
5454
--distributor-host "${SE_DISTRIBUTOR_HOST}" --distributor-port "${SE_DISTRIBUTOR_PORT}" \
5555
--sessionqueue-host "${SE_SESSION_QUEUE_HOST}" --sessionqueue-port "${SE_SESSION_QUEUE_PORT}" \

SessionQueue/start-selenium-grid-session-queue.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ if [ ! -z "$SE_SESSION_QUEUE_PORT" ]; then
3434
PORT_CONFIG="--port ${SE_SESSION_QUEUE_PORT}"
3535
fi
3636

37-
java ${JAVA_OPTS} -jar /opt/selenium/selenium-server.jar sessionqueue \
37+
java ${JAVA_OPTS:-$SE_JAVA_OPTS} -jar /opt/selenium/selenium-server.jar sessionqueue \
3838
--publish-events tcp://"${SE_EVENT_BUS_HOST}":${SE_EVENT_BUS_PUBLISH_PORT} \
3939
--subscribe-events tcp://"${SE_EVENT_BUS_HOST}":${SE_EVENT_BUS_SUBSCRIBE_PORT} \
4040
--session-request-timeout ${SE_SESSION_REQUEST_TIMEOUT} \

Sessions/start-selenium-grid-sessions.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ if [ ! -z "$SE_SESSIONS_PORT" ]; then
3434
PORT_CONFIG="--port ${SE_SESSIONS_PORT}"
3535
fi
3636

37-
java ${JAVA_OPTS} -jar /opt/selenium/selenium-server.jar sessions \
37+
java ${JAVA_OPTS:-$SE_JAVA_OPTS} -jar /opt/selenium/selenium-server.jar sessions \
3838
--publish-events tcp://"${SE_EVENT_BUS_HOST}":${SE_EVENT_BUS_PUBLISH_PORT} \
3939
--subscribe-events tcp://"${SE_EVENT_BUS_HOST}":${SE_EVENT_BUS_SUBSCRIBE_PORT} \
4040
--bind-host ${SE_BIND_HOST} \

Standalone/generate_config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ fi
2626
echo "session-timeout = \"${SE_NODE_SESSION_TIMEOUT}\"" >> "$FILENAME"
2727
echo "override-max-sessions = ${SE_NODE_OVERRIDE_MAX_SESSIONS}" >> "$FILENAME"
2828
echo "detect-drivers = false" >> "$FILENAME"
29-
echo "drain-after-session-count = ${DRAIN_AFTER_SESSION_COUNT}" >> "$FILENAME"
29+
echo "drain-after-session-count = ${DRAIN_AFTER_SESSION_COUNT:-$SE_DRAIN_AFTER_SESSION_COUNT}" >> "$FILENAME"
3030
echo "max-sessions = ${SE_NODE_MAX_SESSIONS}
3131
" >> "$FILENAME"
3232

Standalone/start-selenium-standalone.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ fi
1111
echo "Selenium Grid Standalone configuration: "
1212
cat /opt/selenium/config.toml
1313
echo "Starting Selenium Grid Standalone..."
14-
java ${JAVA_OPTS} -jar /opt/selenium/selenium-server.jar standalone \
14+
java ${JAVA_OPTS:-$SE_JAVA_OPTS} -jar /opt/selenium/selenium-server.jar standalone \
1515
--bind-host ${SE_BIND_HOST} \
1616
--config /opt/selenium/config.toml \
1717
${SE_OPTS}

StandaloneDocker/start-selenium-grid-docker.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ if [ ! -z "$SE_NODE_GRID_URL" ]; then
1414
SE_GRID_URL="--grid-url ${SE_NODE_GRID_URL}"
1515
fi
1616

17-
java ${JAVA_OPTS} -jar /opt/selenium/selenium-server.jar standalone \
17+
java ${JAVA_OPTS:-$SE_JAVA_OPTS} -jar /opt/selenium/selenium-server.jar standalone \
1818
--relax-checks ${SE_RELAX_CHECKS} \
1919
--detect-drivers false \
2020
--bind-host ${SE_BIND_HOST} \

Video/Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,13 @@ RUN mkdir -p /var/run/supervisor /var/log/supervisor /videos
3232
ENTRYPOINT ["/opt/bin/entry_point.sh"]
3333
CMD ["/opt/bin/entry_point.sh"]
3434

35+
ENV DISPLAY_NUM 99
36+
ENV DISPLAY_CONTAINER_NAME selenium
37+
ENV SE_SCREEN_WIDTH 1360
38+
ENV SE_SCREEN_HEIGHT 1020
39+
ENV SE_FRAME_RATE 15
40+
ENV SE_CODEC libx264
41+
ENV SE_PRESET "-preset ultrafast"
42+
ENV FILE_NAME video.mp4
43+
3544
EXPOSE 9000

Video/video.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
#!/bin/sh
22

3-
VIDEO_SIZE=${VIDEO_SIZE:-"1360x1020"}
4-
DISPLAY_CONTAINER_NAME=${DISPLAY_CONTAINER_NAME:-"selenium"}
5-
DISPLAY=${DISPLAY:-"99"}
6-
FILE_NAME=${FILE_NAME:-"video.mp4"}
7-
FRAME_RATE=${FRAME_RATE:-"15"}
8-
CODEC=${CODEC:-"libx264"}
9-
PRESET=${PRESET:-"-preset ultrafast"}
3+
VIDEO_SIZE="${SE_SCREEN_WIDTH}""x""${SE_SCREEN_HEIGHT}"
4+
DISPLAY_CONTAINER_NAME=${DISPLAY_CONTAINER_NAME}
5+
DISPLAY_NUM=${DISPLAY_NUM}
6+
FILE_NAME=${FILE_NAME}
7+
FRAME_RATE=${FRAME_RATE:-$SE_FRAME_RATE}
8+
CODEC=${CODEC:-$SE_CODEC}
9+
PRESET=${PRESET:-$SE_PRESET}
1010

1111
return_code=1
1212
max_attempts=50
1313
attempts=0
1414
echo 'Checking if the display is open...'
1515
until [ $return_code -eq 0 -o $attempts -eq $max_attempts ]; do
16-
xset -display ${DISPLAY_CONTAINER_NAME}:${DISPLAY} b off > /dev/null 2>&1
16+
xset -display ${DISPLAY_CONTAINER_NAME}:${DISPLAY_NUM} b off > /dev/null 2>&1
1717
return_code=$?
1818
if [ $return_code -ne 0 ]; then
1919
echo 'Waiting before next display check...'
@@ -23,5 +23,5 @@ until [ $return_code -eq 0 -o $attempts -eq $max_attempts ]; do
2323
done
2424

2525
# exec replaces the video.sh process with ffmpeg, this makes easier to pass the process termination signal
26-
exec ffmpeg -y -f x11grab -video_size ${VIDEO_SIZE} -r ${FRAME_RATE} -i ${DISPLAY_CONTAINER_NAME}:${DISPLAY}.0 -codec:v ${CODEC} ${PRESET} -pix_fmt yuv420p "/videos/$FILE_NAME"
26+
exec ffmpeg -y -f x11grab -video_size ${VIDEO_SIZE} -r ${FRAME_RATE} -i ${DISPLAY_CONTAINER_NAME}:${DISPLAY_NUM}.0 -codec:v ${CODEC} ${PRESET} -pix_fmt yuv420p "/videos/$FILE_NAME"
2727

0 commit comments

Comments
 (0)