From f89db70bca47577a5d0ca27ecdb87231216a56d6 Mon Sep 17 00:00:00 2001 From: Viet Nguyen Duc Date: Sat, 26 Jul 2025 01:21:34 +0700 Subject: [PATCH] Docker: Move out step to fetch external jars for SessionMap from Base Signed-off-by: Viet Nguyen Duc --- Base/Dockerfile | 11 +---------- Makefile | 5 +++-- Sessions/Dockerfile | 13 +++++++++++++ 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/Base/Dockerfile b/Base/Dockerfile index 726d346e6d..6251b7482c 100644 --- a/Base/Dockerfile +++ b/Base/Dockerfile @@ -6,13 +6,11 @@ LABEL org.opencontainers.image.source="https://github.com/${AUTHORS}/docker-sele # Arguments to define the version of dependencies to download ARG VERSION ARG RELEASE=selenium-${VERSION} -ARG MVN_SELENIUM_VERSION # Default value should be aligned with upstream Selenium (https://github.com/SeleniumHQ/selenium/blob/trunk/MODULE.bazel) ARG OPENTELEMETRY_VERSION=1.51.0 ARG GRPC_VERSION=1.73.0 ARG NETTY_VERSION=4.1.122.Final ARG CS_VERSION=2.1.24 -ARG POSTGRESQL_VERSION=42.7.7 ARG ENVSUBST_VERSION=1.4.5 #Arguments to define the user running Selenium @@ -148,14 +146,7 @@ RUN --mount=type=secret,id=SEL_PASSWD \ io.netty:netty-handler:${NETTY_VERSION} \ io.netty:netty-common:${NETTY_VERSION} \ > /external_jars/.classpath.txt \ - && chmod 664 /external_jars/.classpath.txt \ - && java -jar /tmp/cs fetch --classpath --cache /external_jars \ - org.seleniumhq.selenium:selenium-session-map-jdbc:${MVN_SELENIUM_VERSION} \ - org.postgresql:postgresql:${POSTGRESQL_VERSION} \ - org.seleniumhq.selenium:selenium-session-map-redis:${MVN_SELENIUM_VERSION} \ - # Patch specific version for CVEs in the dependencies - > /external_jars/.classpath_session_map.txt \ - && chmod 664 /external_jars/.classpath_session_map.txt ; \ + && chmod 664 /external_jars/.classpath.txt ; \ fi \ && rm -fr /root/.cache/* \ # (Note that .bashrc is only executed in interactive bash shells.) diff --git a/Makefile b/Makefile index 0ff17b35e1..7c56f25cc5 100644 --- a/Makefile +++ b/Makefile @@ -131,7 +131,7 @@ gen_certs: base: prepare_resources gen_certs cd ./Base && SEL_PASSWD=$(SEL_PASSWD) docker buildx build --platform $(PLATFORMS) $(BUILD_ARGS) --build-arg VERSION=$(BASE_VERSION) --build-arg RELEASE=$(BASE_RELEASE) --build-arg AUTHORS=$(AUTHORS) \ - --build-arg MVN_SELENIUM_VERSION=$(MVN_SELENIUM_VERSION) --secret id=SEL_PASSWD --sbom=true --attest type=provenance,mode=max -t $(NAME)/base:$(TAG_VERSION) . + --secret id=SEL_PASSWD --sbom=true --attest type=provenance,mode=max -t $(NAME)/base:$(TAG_VERSION) . base_nightly: BASE_VERSION=$(BASE_VERSION_NIGHTLY) BASE_RELEASE=$(BASE_RELEASE_NIGHTLY) make base @@ -146,7 +146,8 @@ router: base cd ./Router && docker buildx build --platform $(PLATFORMS) $(BUILD_ARGS) $(FROM_IMAGE_ARGS) -t $(NAME)/router:$(TAG_VERSION) . sessions: base - cd ./Sessions && docker buildx build --platform $(PLATFORMS) $(BUILD_ARGS) $(FROM_IMAGE_ARGS) -t $(NAME)/sessions:$(TAG_VERSION) . + cd ./Sessions && docker buildx build --platform $(PLATFORMS) $(BUILD_ARGS) $(FROM_IMAGE_ARGS) \ + --build-arg MVN_SELENIUM_VERSION=$(MVN_SELENIUM_VERSION) -t $(NAME)/sessions:$(TAG_VERSION) . sessionqueue: base cd ./SessionQueue && docker buildx build --platform $(PLATFORMS) $(BUILD_ARGS) $(FROM_IMAGE_ARGS) -t $(NAME)/session-queue:$(TAG_VERSION) . diff --git a/Sessions/Dockerfile b/Sessions/Dockerfile index f29911e6fc..1949fe1bdd 100644 --- a/Sessions/Dockerfile +++ b/Sessions/Dockerfile @@ -3,6 +3,8 @@ ARG VERSION=latest FROM ${NAMESPACE}/base:${VERSION} ARG AUTHORS LABEL authors=${AUTHORS} +ARG MVN_SELENIUM_VERSION +ARG POSTGRESQL_VERSION=42.7.7 #======================== # Selenium SessionMap Configuration @@ -10,6 +12,17 @@ LABEL authors=${AUTHORS} USER root +RUN if [ -f "/tmp/cs" ]; then \ + java -jar /tmp/cs fetch --classpath --cache /external_jars \ + org.seleniumhq.selenium:selenium-session-map-jdbc:${MVN_SELENIUM_VERSION} \ + org.postgresql:postgresql:${POSTGRESQL_VERSION} \ + org.seleniumhq.selenium:selenium-session-map-redis:${MVN_SELENIUM_VERSION} \ + # Patch specific version for CVEs in the dependencies + > /external_jars/.classpath_session_map.txt \ + && chmod 664 /external_jars/.classpath_session_map.txt ; \ + fi \ + && rm -fr /root/.cache/* + COPY --chown="${SEL_UID}:${SEL_GID}" start-selenium-grid-sessions.sh generate_config \ /opt/bin/ RUN chmod +x /opt/bin/start-selenium-grid-sessions.sh /opt/bin/generate_config