Skip to content

Commit 966a78a

Browse files
authored
Docker: Resolve default component port via env var (#2689)
Signed-off-by: Viet Nguyen Duc <[email protected]>
1 parent 714678d commit 966a78a

20 files changed

+45
-134
lines changed

Base/Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ ARG GRPC_VERSION=1.70.0
1313
ARG NETTY_VERSION=4.1.118.Final
1414
ARG CS_VERSION=2.1.18
1515
ARG POSTGRESQL_VERSION=42.7.5
16-
ARG ENVSUBST_VERSION=1.4.2-patch.124
16+
ARG ENVSUBST_VERSION=1.4.3
1717

1818
#Arguments to define the user running Selenium
1919
ARG SEL_USER=seluser
@@ -161,7 +161,7 @@ COPY --chown="${SEL_UID}:${SEL_GID}" certs/tls.crt certs/tls.key certs/server.jk
161161
# Add envsubst binary
162162
#===================================================
163163
RUN ARCH=$(if [ "$(dpkg --print-architecture)" = "amd64" ]; then echo "x86_64"; else echo "$(dpkg --print-architecture)"; fi) \
164-
&& curl -fsSL https://github.com/NDViet/envsubst/releases/download/v${ENVSUBST_VERSION}/envsubst-$(uname -s)-${ARCH} -o envsubst \
164+
&& curl -fsSL https://github.com/a8m/envsubst/releases/download/v${ENVSUBST_VERSION}/envsubst-$(uname -s)-${ARCH} -o envsubst \
165165
&& chmod +x envsubst \
166166
&& mv envsubst /usr/local/bin \
167167
&& ln -sf /usr/local/bin/envsubst /usr/bin/envsubst

Distributor/Dockerfile

+5
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,9 @@ ENV SE_SESSION_REQUEST_TIMEOUT="300" \
2323
SE_SESSION_RETRY_INTERVAL="15" \
2424
# In seconds, maps to "--healthcheck-interval"
2525
SE_HEALTHCHECK_INTERVAL="120" \
26+
SE_EVENT_BUS_PUBLISH_PORT="4442" \
27+
SE_EVENT_BUS_SUBSCRIBE_PORT="4443" \
28+
SE_SESSIONS_MAP_PORT="5556" \
29+
SE_SESSION_QUEUE_PORT="5559" \
30+
SE_DISTRIBUTOR_PORT="5553" \
2631
SE_OTEL_SERVICE_NAME="selenium-distributor"

ENV_VARIABLES.md

+6-8
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
| SE_NODE_GRID_URL | | Node config, public URL of the Grid as a whole (typically the address of the Hub or the Router) | --grid-url |
2727
| SE_HUB_HOST | | Hub config, host address the Hub should listen on | --host |
2828
| SE_ROUTER_HOST | | Router config, host address the Router should listen on | --host |
29-
| SE_HUB_PORT | | Hub config, port the Hub should listen on (default 4444) | --port |
30-
| SE_ROUTER_PORT | | Router config, port the Router should listen on (default 4444) | --port |
29+
| SE_HUB_PORT | 4444 | Hub config, port the Hub should listen on (default 4444) | --port |
30+
| SE_ROUTER_PORT | 4444 | Router config, port the Router should listen on (default 4444) | --port |
3131
| SE_NODE_GRID_GRAPHQL_URL | | Video recording config, GraphQL URL to query test metadata for dynamic file name | |
3232
| SE_VIDEO_FILE_NAME_TRIM_REGEX | [:alnum:]-_ | Bash regex to trim the file name if it is too long | |
3333
| SE_VIDEO_FILE_NAME_SUFFIX | | Append a suffix session id along with test metadata | |
@@ -39,7 +39,7 @@
3939
| SE_RCLONE_ | | | |
4040
| SE_OPTS | | | |
4141
| SE_EVENT_BUS_HOST | | | |
42-
| SE_EVENT_BUS_PORT | | | |
42+
| SE_EVENT_BUS_PORT | 5557 | | |
4343
| SE_LOG_LEVEL | INFO | | |
4444
| SE_HTTP_LOGS | false | | |
4545
| SE_STRUCTURED_LOGS | false | | |
@@ -92,17 +92,15 @@
9292
| SE_HEALTHCHECK_INTERVAL | 120 | | |
9393
| SE_RELAX_CHECKS | true | | |
9494
| SE_SESSION_QUEUE_HOST | | | |
95-
| SE_SESSION_QUEUE_PORT | | | |
95+
| SE_SESSION_QUEUE_PORT | 5559 | | |
9696
| SE_VIDEO_FOLDER | | | |
9797
| SE_LOG_LISTEN_GRAPHQL | | | |
9898
| SE_NODE_PRESTOP_WAIT_STRATEGY | | | |
99-
| SE_SESSIONS_HOST | | | |
100-
| SE_SESSIONS_PORT | | | |
10199
| SE_SESSIONS_MAP_EXTERNAL_DATASTORE | false | | |
102100
| SE_SESSIONS_MAP_HOST | | | |
103-
| SE_SESSIONS_MAP_PORT | | | |
101+
| SE_SESSIONS_MAP_PORT | 5556 | | |
104102
| SE_DISTRIBUTOR_HOST | | | |
105-
| SE_DISTRIBUTOR_PORT | | | |
103+
| SE_DISTRIBUTOR_PORT | 5553 | | |
106104
| SE_GRID_URL | | | |
107105
| SE_NODE_DOCKER_CONFIG_FILENAME | | | |
108106
| SE_NODE_GRACEFUL_SHUTDOWN | | | |

EventBus/Dockerfile

+4-1
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,7 @@ COPY --chown="${SEL_UID}:${SEL_GID}" start-selenium-grid-eventbus.sh \
2222

2323
COPY selenium-grid-eventbus.conf /etc/supervisor/conf.d/
2424

25-
ENV SE_OTEL_SERVICE_NAME="selenium-event-bus"
25+
ENV SE_OTEL_SERVICE_NAME="selenium-event-bus" \
26+
SE_EVENT_BUS_PUBLISH_PORT="4442" \
27+
SE_EVENT_BUS_SUBSCRIBE_PORT="4443" \
28+
SE_EVENT_BUS_PORT="5557"

Hub/Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ ENV SE_SESSION_REQUEST_TIMEOUT="300" \
2222
SE_HEALTHCHECK_INTERVAL="120" \
2323
# Boolean value, maps "--relax-checks"
2424
SE_RELAX_CHECKS="true" \
25+
SE_HUB_PORT="4444" \
2526
SE_OTEL_SERVICE_NAME="selenium-hub"
2627

2728
COPY --chown="${SEL_UID}:${SEL_GID}" start-selenium-grid-hub.sh \

NodeDocker/Dockerfile

+3-1
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,6 @@ COPY --chown="${SEL_UID}:${SEL_GID}" config.toml /opt/selenium/
2929

3030
COPY selenium-grid-docker.conf /etc/supervisor/conf.d/
3131

32-
ENV SE_OTEL_SERVICE_NAME="selenium-node-docker"
32+
ENV SE_OTEL_SERVICE_NAME="selenium-node-docker" \
33+
SE_EVENT_BUS_PUBLISH_PORT="4442" \
34+
SE_EVENT_BUS_SUBSCRIBE_PORT="4443"

Router/Dockerfile

+4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ USER ${SEL_UID}
1414
ENV SE_SESSION_REQUEST_TIMEOUT="300" \
1515
# In seconds, maps to "--session-retry-interval"
1616
SE_SESSION_RETRY_INTERVAL="15" \
17+
SE_DISTRIBUTOR_PORT="5553" \
18+
SE_SESSIONS_MAP_PORT="5556" \
19+
SE_SESSION_QUEUE_PORT="5559" \
20+
SE_ROUTER_PORT="4444" \
1721
SE_OTEL_SERVICE_NAME="selenium-router"
1822

1923
EXPOSE 4444

SessionQueue/Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ USER ${SEL_UID}
1414
ENV SE_SESSION_REQUEST_TIMEOUT="300" \
1515
# In seconds, maps to "--session-retry-interval"
1616
SE_SESSION_RETRY_INTERVAL="15" \
17+
SE_SESSION_QUEUE_PORT="5559" \
1718
SE_OTEL_SERVICE_NAME="selenium-session-queue"
1819

1920
EXPOSE 5559

Sessions/Dockerfile

+3
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,7 @@ EXPOSE 5556
2222

2323
ENV SE_OTEL_SERVICE_NAME="selenium-session-map" \
2424
GENERATE_CONFIG="true" \
25+
SE_EVENT_BUS_PUBLISH_PORT="4442" \
26+
SE_EVENT_BUS_SUBSCRIBE_PORT="4443" \
27+
SE_SESSIONS_MAP_PORT="5556" \
2528
SE_SESSIONS_MAP_EXTERNAL_DATASTORE="false"

Sessions/start-selenium-grid-sessions.sh

+6-6
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ if [ ! -z "$SE_OPTS" ]; then
4141
echo "Appending Selenium options: ${SE_OPTS}"
4242
fi
4343

44-
if [ ! -z "$SE_SESSIONS_HOST" ]; then
45-
echo "Using SE_SESSIONS_HOST: ${SE_SESSIONS_HOST}"
46-
HOST_CONFIG="--host ${SE_SESSIONS_HOST}"
44+
if [ ! -z "${SE_SESSIONS_MAP_HOST}" ]; then
45+
echo "Using SE_SESSIONS_MAP_HOST: ${SE_SESSIONS_MAP_HOST}"
46+
HOST_CONFIG="--host ${SE_SESSIONS_MAP_HOST}"
4747
fi
4848

49-
if [ ! -z "$SE_SESSIONS_PORT" ]; then
50-
echo "Using SE_SESSIONS_PORT: ${SE_SESSIONS_PORT}"
51-
PORT_CONFIG="--port ${SE_SESSIONS_PORT}"
49+
if [ ! -z "${SE_SESSIONS_MAP_PORT}" ]; then
50+
echo "Using SE_SESSIONS_MAP_PORT: ${SE_SESSIONS_MAP_PORT}"
51+
PORT_CONFIG="--port ${SE_SESSIONS_MAP_PORT}"
5252
fi
5353

5454
if [ ! -z "$SE_LOG_LEVEL" ]; then

charts/selenium-grid/templates/session-map-deployment.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ spec:
4747
fieldPath: status.hostIP
4848
- name: SE_OTEL_SERVICE_NAME
4949
value: '{{ template "seleniumGrid.sessionMap.fullname" . }}'
50-
- name: SE_SESSIONS_HOST
50+
- name: SE_SESSIONS_MAP_HOST
5151
valueFrom:
5252
fieldRef:
5353
fieldPath: status.podIP
54-
- name: SE_SESSIONS_PORT
54+
- name: SE_SESSIONS_MAP_PORT
5555
value: {{ .Values.components.sessionMap.port | quote }}
5656
{{- with .Values.components.extraEnvironmentVariables }}
5757
{{- tpl (toYaml .) $ | nindent 12 }}

docker-compose-v3-full-grid-dev.yml

-16
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# To execute this docker compose yml file use `docker compose -f docker-compose-v3-full-grid-dev.yml up`
22
# Add the `-d` flag at the end for detached execution
33
# To stop the execution, hit Ctrl+C, and then `docker compose -f docker-compose-v3-full-grid-dev.yml down`
4-
version: "3"
54
services:
65
selenium-event-bus:
76
image: selenium/event-bus:4.29.0-20250222
@@ -24,8 +23,6 @@ services:
2423
- selenium-event-bus
2524
environment:
2625
- SE_EVENT_BUS_HOST=selenium-event-bus
27-
- SE_EVENT_BUS_PUBLISH_PORT=4442
28-
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
2926

3027
selenium-session-queue:
3128
image: selenium/session-queue:4.29.0-20250222
@@ -48,12 +45,8 @@ services:
4845
- selenium-session-queue
4946
environment:
5047
- SE_EVENT_BUS_HOST=selenium-event-bus
51-
- SE_EVENT_BUS_PUBLISH_PORT=4442
52-
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
5348
- SE_SESSIONS_MAP_HOST=selenium-sessions
54-
- SE_SESSIONS_MAP_PORT=5556
5549
- SE_SESSION_QUEUE_HOST=selenium-session-queue
56-
- SE_SESSION_QUEUE_PORT=5559
5750

5851
selenium-router:
5952
image: selenium/router:4.29.0-20250222
@@ -68,11 +61,8 @@ services:
6861
- selenium-session-queue
6962
environment:
7063
- SE_DISTRIBUTOR_HOST=selenium-distributor
71-
- SE_DISTRIBUTOR_PORT=5553
7264
- SE_SESSIONS_MAP_HOST=selenium-sessions
73-
- SE_SESSIONS_MAP_PORT=5556
7465
- SE_SESSION_QUEUE_HOST=selenium-session-queue
75-
- SE_SESSION_QUEUE_PORT=5559
7666

7767
chrome:
7868
image: selenium/node-chrome:4.29.0-20250222
@@ -83,8 +73,6 @@ services:
8373
- selenium-event-bus
8474
environment:
8575
- SE_EVENT_BUS_HOST=selenium-event-bus
86-
- SE_EVENT_BUS_PUBLISH_PORT=4442
87-
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
8876

8977
edge:
9078
image: selenium/node-edge:4.29.0-20250222
@@ -95,8 +83,6 @@ services:
9583
- selenium-event-bus
9684
environment:
9785
- SE_EVENT_BUS_HOST=selenium-event-bus
98-
- SE_EVENT_BUS_PUBLISH_PORT=4442
99-
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
10086

10187
firefox:
10288
image: selenium/node-firefox:4.29.0-20250222
@@ -107,5 +93,3 @@ services:
10793
- selenium-event-bus
10894
environment:
10995
- SE_EVENT_BUS_HOST=selenium-event-bus
110-
- SE_EVENT_BUS_PUBLISH_PORT=4442
111-
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443

docker-compose-v3-full-grid-external-datastore.yml

-16
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# To execute this docker compose yml file use `docker compose -f docker-compose-v3-full-grid.yml up`
22
# Add the `-d` flag at the end for detached execution
33
# To stop the execution, hit Ctrl+C, and then `docker compose -f docker-compose-v3-full-grid.yml down`
4-
version: "3"
54
services:
65
selenium-event-bus:
76
image: selenium/event-bus:4.29.0-20250222
@@ -20,8 +19,6 @@ services:
2019
- selenium-event-bus
2120
environment:
2221
- SE_EVENT_BUS_HOST=selenium-event-bus
23-
- SE_EVENT_BUS_PUBLISH_PORT=4442
24-
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
2522
- SE_SESSIONS_MAP_EXTERNAL_DATASTORE=true
2623
- SE_SESSIONS_MAP_EXTERNAL_IMPLEMENTATION=org.openqa.selenium.grid.sessionmap.jdbc.JdbcBackedSessionMap
2724
- SE_SESSIONS_MAP_EXTERNAL_JDBC_URL=jdbc:postgresql://postgresql:5432/selenium_sessions
@@ -68,12 +65,8 @@ services:
6865
- selenium-session-queue
6966
environment:
7067
- SE_EVENT_BUS_HOST=selenium-event-bus
71-
- SE_EVENT_BUS_PUBLISH_PORT=4442
72-
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
7368
- SE_SESSIONS_MAP_HOST=selenium-sessions
74-
- SE_SESSIONS_MAP_PORT=5556
7569
- SE_SESSION_QUEUE_HOST=selenium-session-queue
76-
- SE_SESSION_QUEUE_PORT=5559
7770

7871
selenium-router:
7972
image: selenium/router:4.29.0-20250222
@@ -86,11 +79,8 @@ services:
8679
- selenium-session-queue
8780
environment:
8881
- SE_DISTRIBUTOR_HOST=selenium-distributor
89-
- SE_DISTRIBUTOR_PORT=5553
9082
- SE_SESSIONS_MAP_HOST=selenium-sessions
91-
- SE_SESSIONS_MAP_PORT=5556
9283
- SE_SESSION_QUEUE_HOST=selenium-session-queue
93-
- SE_SESSION_QUEUE_PORT=5559
9484

9585
chrome:
9686
image: selenium/node-chrome:4.29.0-20250222
@@ -99,8 +89,6 @@ services:
9989
- selenium-event-bus
10090
environment:
10191
- SE_EVENT_BUS_HOST=selenium-event-bus
102-
- SE_EVENT_BUS_PUBLISH_PORT=4442
103-
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
10492

10593
edge:
10694
image: selenium/node-edge:4.29.0-20250222
@@ -109,8 +97,6 @@ services:
10997
- selenium-event-bus
11098
environment:
11199
- SE_EVENT_BUS_HOST=selenium-event-bus
112-
- SE_EVENT_BUS_PUBLISH_PORT=4442
113-
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
114100

115101
firefox:
116102
image: selenium/node-firefox:4.29.0-20250222
@@ -119,5 +105,3 @@ services:
119105
- selenium-event-bus
120106
environment:
121107
- SE_EVENT_BUS_HOST=selenium-event-bus
122-
- SE_EVENT_BUS_PUBLISH_PORT=4442
123-
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443

docker-compose-v3-full-grid-nightly.yml

-16
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# To execute this docker compose yml file use `docker compose -f docker-compose-v3-full-grid-nightly.yml up --force-recreate`
22
# Add the `-d` flag at the end for detached execution
33
# To stop the execution, hit Ctrl+C, and then `docker compose -f docker-compose-v3-full-grid-nightly.yml down`
4-
version: "3"
54
services:
65
selenium-event-bus:
76
image: selenium/event-bus:nightly
@@ -20,8 +19,6 @@ services:
2019
- selenium-event-bus
2120
environment:
2221
- SE_EVENT_BUS_HOST=selenium-event-bus
23-
- SE_EVENT_BUS_PUBLISH_PORT=4442
24-
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
2522

2623
selenium-session-queue:
2724
image: selenium/session-queue:nightly
@@ -40,12 +37,8 @@ services:
4037
- selenium-session-queue
4138
environment:
4239
- SE_EVENT_BUS_HOST=selenium-event-bus
43-
- SE_EVENT_BUS_PUBLISH_PORT=4442
44-
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
4540
- SE_SESSIONS_MAP_HOST=selenium-sessions
46-
- SE_SESSIONS_MAP_PORT=5556
4741
- SE_SESSION_QUEUE_HOST=selenium-session-queue
48-
- SE_SESSION_QUEUE_PORT=5559
4942

5043
selenium-router:
5144
image: selenium/router:nightly
@@ -58,11 +51,8 @@ services:
5851
- selenium-session-queue
5952
environment:
6053
- SE_DISTRIBUTOR_HOST=selenium-distributor
61-
- SE_DISTRIBUTOR_PORT=5553
6254
- SE_SESSIONS_MAP_HOST=selenium-sessions
63-
- SE_SESSIONS_MAP_PORT=5556
6455
- SE_SESSION_QUEUE_HOST=selenium-session-queue
65-
- SE_SESSION_QUEUE_PORT=5559
6656

6757
chrome:
6858
image: selenium/node-chrome:nightly
@@ -71,8 +61,6 @@ services:
7161
- selenium-event-bus
7262
environment:
7363
- SE_EVENT_BUS_HOST=selenium-event-bus
74-
- SE_EVENT_BUS_PUBLISH_PORT=4442
75-
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
7664

7765
edge:
7866
image: selenium/node-edge:nightly
@@ -81,8 +69,6 @@ services:
8169
- selenium-event-bus
8270
environment:
8371
- SE_EVENT_BUS_HOST=selenium-event-bus
84-
- SE_EVENT_BUS_PUBLISH_PORT=4442
85-
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
8672

8773
firefox:
8874
image: selenium/node-firefox:nightly
@@ -91,8 +77,6 @@ services:
9177
- selenium-event-bus
9278
environment:
9379
- SE_EVENT_BUS_HOST=selenium-event-bus
94-
- SE_EVENT_BUS_PUBLISH_PORT=4442
95-
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
9680

9781
chrome_video:
9882
image: selenium/video:nightly

0 commit comments

Comments
 (0)