44# Arguments to define the version of dependencies to download
55ARG VERSION
66ARG RELEASE=selenium-${VERSION}
7- ARG GH_ORG =SeleniumHQ
7+ ARG AUTHORS =SeleniumHQ
88# Default value should be aligned with upstream Selenium (https://github.com/SeleniumHQ/selenium/blob/trunk/java/maven_deps.bzl)
99ARG OPENTELEMETRY_VERSION=1.36.0
1010ARG GRPC_VERSION=1.62.2
@@ -15,27 +15,31 @@ ARG SEL_GROUP=${SEL_USER}
1515ARG SEL_PASSWD=secret
1616ARG UID=1200
1717ARG GID=1201
18-
19- USER root
20- # ================================================
21- # Customize sources for apt-get
22- # ================================================
23- RUN echo "deb http://archive.ubuntu.com/ubuntu jammy main universe\n " > /etc/apt/sources.list \
24- && echo "deb http://archive.ubuntu.com/ubuntu jammy-updates main universe\n " >> /etc/apt/sources.list \
25- && echo "deb http://security.ubuntu.com/ubuntu jammy-security main universe\n " >> /etc/apt/sources.list
18+ ARG TZ="UTC"
19+ ARG JRE_VERSION=17
2620ARG TARGETARCH=amd64
2721ARG TARGETVARIANT
2822
29- # No interactive frontend during docker build
23+ USER root
24+
3025ENV DEBIAN_FRONTEND=noninteractive \
31- DEBCONF_NONINTERACTIVE_SEEN=true
26+ # No interactive frontend during docker build
27+ DEBCONF_NONINTERACTIVE_SEEN=true \
28+ SEL_USER=${SEL_USER} \
29+ SEL_UID=${UID} \
30+ SEL_GID=${GID} \
31+ HOME=/home/${SEL_USER} \
32+ TZ=${TZ} \
33+ SEL_DOWNLOAD_DIR=${HOME}/Downloads
3234
3335# ========================
3436# Miscellaneous packages
3537# Includes minimal runtime used for executing non GUI Java programs
3638# ========================
37- ARG JRE_VERSION=17
38- RUN apt-get -qqy update \
39+ RUN echo "deb http://archive.ubuntu.com/ubuntu jammy main universe\n " > /etc/apt/sources.list \
40+ && echo "deb http://archive.ubuntu.com/ubuntu jammy-updates main universe\n " >> /etc/apt/sources.list \
41+ && echo "deb http://security.ubuntu.com/ubuntu jammy-security main universe\n " >> /etc/apt/sources.list \
42+ && apt-get -qqy update \
3943 && apt-get upgrade -yq \
4044 && apt-get -qqy --no-install-recommends install \
4145 acl \
@@ -56,40 +60,24 @@ RUN apt-get -qqy update \
5660 && echo "deb [signed-by=/etc/apt/keyrings/adoptium.asc] https://packages.adoptium.net/artifactory/deb $(awk -F= '/^VERSION_CODENAME/{print$2}' /etc/os-release) main" | tee /etc/apt/sources.list.d/adoptium.list >dev/null \
5761 && apt-get -qqy update \
5862 && apt-get -qqy --no-install-recommends install temurin-${JRE_VERSION}-jre -y \
59- && rm -rf /var/lib/apt/lists/* /var/cache/apt/*
60-
61- # ===================
62-
63- RUN if [ $TARGETARCH = "arm" ] && [ $TARGETVARIANT = "v7" ]; then \
63+ && if [ "${TARGETARCH}" = "arm" ] && [ "${TARGETVARIANT}" = "v7" ]; then \
6464 export ARCH=armhf ; \
6565 else \
66- export ARCH=$TARGETARCH ; \
66+ export ARCH=${ TARGETARCH} ; \
6767 fi \
68- && sed -i 's/securerandom\. source=file:\/ dev\/ random/securerandom\. source=file:\/ dev\/ urandom/' ./usr/lib/jvm/temurin-${JRE_VERSION}-jre-$ARCH/conf/security/java.security
69-
70-
68+ && sed -i 's/securerandom\. source=file:\/ dev\/ random/securerandom\. source=file:\/ dev\/ urandom/' ./usr/lib/jvm/temurin-${JRE_VERSION}-jre-${ARCH}/conf/security/java.security \
69+ && rm -rf /var/lib/apt/lists/* /var/cache/apt/* \
7170# ===================
7271# Timezone settings
7372# Possible alternative: https://github.com/docker/docker/issues/3359#issuecomment-32150214
7473# ===================
75- ENV TZ "UTC"
76- RUN ln -fs /usr/share/zoneinfo/${TZ} /etc/localtime && \
74+ && ln -fs /usr/share/zoneinfo/${TZ} /etc/localtime && \
7775 dpkg-reconfigure -f noninteractive tzdata && \
78- cat /etc/timezone
79-
80- # ======================================
81- # Configure environement
82- # ======================================
83- ENV SEL_USER=${SEL_USER}
84- ENV SEL_UID=${UID}
85- ENV SEL_GID=${GID}
86- ENV HOME=/home/${SEL_USER}
87- ENV SEL_DOWNLOAD_DIR=${HOME}/Downloads
88-
76+ cat /etc/timezone \
8977# ========================================
90- # Add normal user and group with passwordless sudo
78+ # Add normal user and group without password sudo
9179# ========================================
92- RUN groupadd ${SEL_GROUP} \
80+ && groupadd ${SEL_GROUP} \
9381 --gid ${SEL_GID} \
9482 && useradd ${SEL_USER} \
9583 --create-home \
@@ -98,75 +86,63 @@ RUN groupadd ${SEL_GROUP} \
9886 --uid ${SEL_UID} \
9987 && usermod -a -G sudo ${SEL_USER} \
10088 && echo 'ALL ALL = (ALL) NOPASSWD: ALL' >> /etc/sudoers \
101- && echo "${SEL_USER}:${SEL_PASSWD}" | chpasswd
102-
103- # ======================================
104- # Add Grid check script
105- # ======================================
106- COPY --chown="${SEL_UID}:${SEL_GID}" check-grid.sh entry_point.sh /opt/bin/
107-
108- # ======================================
109- # Add Supervisor configuration file
110- # ======================================
111- COPY supervisord.conf /etc
112-
89+ && echo "${SEL_USER}:${SEL_PASSWD}" | chpasswd \
11390# ==========
11491# Selenium & relaxing permissions for OpenShift and other non-sudo environments
11592# ==========
116- RUN mkdir -p /opt/selenium /opt/selenium/assets /var/run/supervisor /var/log/supervisor ${SEL_DOWNLOAD_DIR} \
93+ && mkdir -p /opt/selenium /opt/selenium/assets /var/run/supervisor /var/log/supervisor ${SEL_DOWNLOAD_DIR} \
11794 ${HOME}/.mozilla ${HOME}/.vnc $HOME/.pki/nssdb \
95+ # NSSDB initialization with an empty password
96+ && certutil -d sql:$HOME/.pki/nssdb -N --empty-password \
11897 && touch /opt/selenium/config.toml \
11998 && chown -R ${SEL_USER}:${SEL_GROUP} /opt/selenium /var/run/supervisor /var/log/supervisor /etc/passwd ${HOME} \
12099 && chmod -R 775 /opt/selenium /var/run/supervisor /var/log/supervisor /etc/passwd ${HOME} \
121- && wget --no-verbose https://github.com/${GH_ORG }/selenium/releases/download/${RELEASE}/selenium-server-${VERSION}.jar \
100+ && wget --no-verbose https://github.com/${AUTHORS }/selenium/releases/download/${RELEASE}/selenium-server-${VERSION}.jar \
122101 -O /opt/selenium/selenium-server.jar \
123102 && echo "${SEL_PASSWD}" > /opt/selenium/initialPasswd \
124103 && chgrp -R 0 /opt/selenium ${HOME} /opt/selenium/assets /var/run/supervisor /var/log/supervisor \
125104 && chmod -R g=u /opt/selenium ${HOME} /opt/selenium/assets /var/run/supervisor /var/log/supervisor \
126105 && setfacl -Rm u:${SEL_USER}:rwx /opt /opt/selenium ${HOME} /opt/selenium/assets /var/run/supervisor /var/log/supervisor \
127- && setfacl -Rm g:${SEL_GROUP}:rwx /opt /opt/selenium ${HOME} /opt/selenium/assets /var/run/supervisor /var/log/supervisor
128-
106+ && setfacl -Rm g:${SEL_GROUP}:rwx /opt /opt/selenium ${HOME} /opt/selenium/assets /var/run/supervisor /var/log/supervisor \
129107# =====
130- # Download observability related jaegar jars and make them available in a separate directory
108+ # Download observability related OpenTelemetry jars and make them available in a separate directory
131109# so that the container can skip downloading them everytime it comes up
132110# =====
133- RUN curl -fLo /tmp/cs https://github.com/coursier/launchers/raw/master/coursier \
111+ && curl -fLo /tmp/cs https://github.com/coursier/launchers/raw/master/coursier \
134112 && chmod +x /tmp/cs \
135113 && mkdir -p /external_jars \
136- && chmod -R 775 /external_jars
137-
138- RUN /tmp/cs fetch --classpath --cache /external_jars \
114+ && chmod -R 775 /external_jars \
115+ && /tmp/cs fetch --classpath --cache /external_jars \
139116 io.opentelemetry:opentelemetry-exporter-otlp:${OPENTELEMETRY_VERSION} \
140- io.grpc:grpc-netty:${GRPC_VERSION} > /external_jars/.classpath.txt
117+ io.grpc:grpc-netty:${GRPC_VERSION} > /external_jars/.classpath.txt \
118+ && chmod 664 /external_jars/.classpath.txt \
119+ && rm -fr /root/.cache/* \
120+ # (Note that .bashrc is only executed in interactive bash shells.)
121+ && echo 'if [[ $(ulimit -n) -gt 200000 ]]; then echo "WARNING: Very high value reported by \" ulimit -n\" . Consider passing \" --ulimit nofile=32768\" to \" docker run\" ."; fi' >> ${HOME}/.bashrc
141122
142- RUN chmod 664 /external_jars/.classpath.txt
143- RUN rm -fr /root/.cache/*
123+ # ======================================
124+ # Add Grid check script
125+ # ======================================
126+ COPY --chown="${SEL_UID}:${SEL_GID}" check-grid.sh entry_point.sh /opt/bin/
127+
128+ # ======================================
129+ # Add Supervisor configuration file
130+ # ======================================
131+ COPY supervisord.conf /etc
144132
145133# ===================================================
146134# Run the following commands as non-privileged user
147135# ===================================================
148136USER ${SEL_UID}:${SEL_GID}
149137
150- # ==========
151- # NSSDB initialization with an empty password
152- # ==========
153- RUN certutil -d sql:$HOME/.pki/nssdb -N --empty-password
154-
155- # Boolean value, maps "--bind-host"
156- ENV SE_BIND_HOST false
157- # Boolean value, maps "--reject-unsupported-caps"
158- ENV SE_REJECT_UNSUPPORTED_CAPS false
159-
160- ENV SE_OTEL_JAVA_GLOBAL_AUTOCONFIGURE_ENABLED true
161- ENV SE_OTEL_TRACES_EXPORTER "otlp"
162-
163- # A too high maximum number of file descriptors (with the default value
164- # inherited from the docker host) can cause issues with some of our tools:
165- # - sanitizers hanging: https://github.com/google/sanitizers/issues/1662
166- # - valgrind crashing: https://stackoverflow.com/a/75293014
167- # This is not be a problem on our CI hosts, but developers who run the image
168- # on their machines may run into this (e.g., on Arch Linux), so warn them.
169- # (Note that .bashrc is only executed in interactive bash shells.)
170- RUN echo 'if [[ $(ulimit -n) -gt 200000 ]]; then echo "WARNING: Very high value reported by \" ulimit -n\" . Consider passing \" --ulimit nofile=32768\" to \" docker run\" ."; fi' >> ${HOME}/.bashrc
138+ # ======================================
139+ # Configure environement
140+ # ======================================
141+ # Boolean value, maps "--bind-host"
142+ ENV SE_BIND_HOST=false \
143+ # Boolean value, maps "--reject-unsupported-caps"
144+ SE_REJECT_UNSUPPORTED_CAPS=false \
145+ SE_OTEL_JAVA_GLOBAL_AUTOCONFIGURE_ENABLED=true \
146+ SE_OTEL_TRACES_EXPORTER="otlp"
171147
172148CMD ["/opt/bin/entry_point.sh" ]
0 commit comments