Skip to content

Commit f6e4169

Browse files
authored
Refactoring config generation, reducing copy & paste (#1155)
1 parent b1a5c9f commit f6e4169

File tree

7 files changed

+16
-108
lines changed

7 files changed

+16
-108
lines changed

NodeBase/Dockerfile.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,4 +148,11 @@ ENV DBUS_SESSION_BUS_ADDRESS=/dev/null
148148
# Creating base directory for Xvfb
149149
RUN sudo mkdir -p /tmp/.X11-unix && sudo chmod 1777 /tmp/.X11-unix
150150

151+
# Copying configuration script generator
152+
COPY generate_config /opt/bin/generate_config
153+
154+
# Generating a default config during build time
155+
RUN /opt/bin/generate_config
156+
157+
151158
EXPOSE 5900
Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,29 @@
11
#!/bin/bash
22

3-
# OPERA_VERSION=$(opera -version)
4-
5-
echo "[node]
6-
max-concurrent-sessions = ${SE_NODE_MAX_CONCURRENT_SESSIONS}
7-
[events]
3+
echo "[events]
84
publish = \"tcp://${SE_EVENT_BUS_HOST}:${SE_EVENT_BUS_PUBLISH_PORT}\"
95
subscribe = \"tcp://${SE_EVENT_BUS_HOST}:${SE_EVENT_BUS_SUBSCRIBE_PORT}\"
106
" > /opt/selenium/config.toml
117

12-
138
if [[ -z "${SE_NODE_HOST}" ]] || [[ -z "${SE_NODE_PORT}" ]]; then
14-
echo "SE_NODE_HOST and SE_NODE_PORT not found."
15-
else
16-
echo "[server]" >> /opt/selenium/config.toml
17-
fi
18-
19-
if [[ -z "${SE_NODE_HOST}" ]] || [[ -z "${SE_NODE_PORT}" ]]; then
20-
echo "SE_NODE_HOST and SE_NODE_PORT not found."
9+
echo "Configuring server..."
2110
else
2211
echo "[server]" >> /opt/selenium/config.toml
2312
fi
2413

2514
if [[ -z "${SE_NODE_HOST}" ]]; then
26-
echo "Using default SE_NODE_HOST."
15+
echo "Setting up SE_NODE_HOST..."
2716
else
2817
echo "hostname = \"${SE_NODE_HOST}\"" >> /opt/selenium/config.toml
2918
fi
3019

3120
if [[ -z "${SE_NODE_PORT}" ]]; then
32-
echo "Using default SE_NODE_PORT."
21+
echo "Setting up SE_NODE_PORT..."
3322
else
3423
echo "port = \"${SE_NODE_PORT}\"" >> /opt/selenium/config.toml
3524
fi
25+
26+
echo "[node]
27+
max-concurrent-sessions = ${SE_NODE_MAX_CONCURRENT_SESSIONS}
28+
" >> /opt/selenium/config.toml
29+

NodeChrome/Dockerfile.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,3 @@ RUN if [ -z "$CHROME_DRIVER_VERSION" ]; \
4646
&& mv /opt/selenium/chromedriver /opt/selenium/chromedriver-$CHROME_DRIVER_VERSION \
4747
&& chmod 755 /opt/selenium/chromedriver-$CHROME_DRIVER_VERSION \
4848
&& sudo ln -fs /opt/selenium/chromedriver-$CHROME_DRIVER_VERSION /usr/bin/chromedriver
49-
50-
COPY generate_config /opt/bin/generate_config
51-
52-
# Generating a default config during build time
53-
RUN /opt/bin/generate_config

NodeChrome/generate_config

Lines changed: 0 additions & 35 deletions
This file was deleted.

NodeFirefox/Dockerfile.txt

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,3 @@ RUN GK_VERSION=$(if [ ${GECKODRIVER_VERSION:-latest} = "latest" ]; then echo "0.
3131
&& ln -fs /opt/geckodriver-$GK_VERSION /usr/bin/geckodriver
3232

3333
USER 1200
34-
35-
COPY generate_config /opt/bin/generate_config
36-
37-
# Generating a default config during build time
38-
RUN /opt/bin/generate_config
39-
40-
#==========
41-
# Relaxing permissions for OpenShift and other non-sudo environments
42-
#==========
43-
RUN sudo chmod -R 777 ${HOME} \
44-
&& sudo chgrp -R 0 ${HOME} \
45-
&& sudo chmod -R g=u ${HOME}

NodeFirefox/generate_config

Lines changed: 0 additions & 36 deletions
This file was deleted.

NodeOpera/Dockerfile.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,3 @@ RUN LATEST_VERSION=$(curl -s https://api.github.com/repos/operasoftware/operachr
5151
&& rm -rf /tmp/operadriver_linux64* \
5252
&& chmod 755 /opt/selenium/operadriver-${OPERA_DRIVER_VERSION} \
5353
&& sudo ln -fs /opt/selenium/operadriver-${OPERA_DRIVER_VERSION} /usr/bin/operadriver
54-
55-
COPY generate_config /opt/bin/generate_config
56-
57-
# Generating a default config during build time
58-
RUN /opt/bin/generate_config

0 commit comments

Comments
 (0)