Skip to content

Docker: Move out step to fetch external jars for SessionMap from Base #2909

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 27, 2025

Conversation

VietND96
Copy link
Member

@VietND96 VietND96 commented Jul 25, 2025

User description

Thanks for contributing to the Docker-Selenium project!
A PR well described will help maintainers to quickly review and merge it

Before submitting your PR, please check our contributing guidelines, applied for this repository.
Avoid large PRs, help reviewers by making them as simple and short as possible.

Description

Reducing specific artifacts in Base layer.

Motivation and Context

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have read the contributing document.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

PR Type

Enhancement


Description

  • Move SessionMap external jar fetching from Base to Sessions Dockerfile

  • Remove MVN_SELENIUM_VERSION and POSTGRESQL_VERSION from Base image

  • Add specific build arguments to Sessions container build

  • Optimize Docker layer separation for SessionMap dependencies


Diagram Walkthrough

flowchart LR
  Base["Base Dockerfile"] -- "Remove SessionMap jars" --> Sessions["Sessions Dockerfile"]
  Base -- "Remove build args" --> Makefile["Makefile"]
  Sessions -- "Add jar fetching" --> Dependencies["SessionMap Dependencies"]
Loading

File Walkthrough

Relevant files
Enhancement
Dockerfile
Remove SessionMap dependencies from base image                     

Base/Dockerfile

  • Remove MVN_SELENIUM_VERSION and POSTGRESQL_VERSION build arguments
  • Remove SessionMap jar fetching logic from base image
  • Remove .classpath_session_map.txt generation step
+1/-10   
Dockerfile
Add SessionMap jar dependencies to Sessions image               

Sessions/Dockerfile

  • Add MVN_SELENIUM_VERSION and POSTGRESQL_VERSION build arguments
  • Add jar fetching logic for SessionMap dependencies
  • Generate .classpath_session_map.txt file in Sessions container
+13/-0   
Configuration changes
Makefile
Update build arguments for sessions target                             

Makefile

  • Remove MVN_SELENIUM_VERSION build argument from base target
  • Add MVN_SELENIUM_VERSION build argument to sessions target
+3/-2     

Copy link
Contributor

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Missing Validation

The jar fetching logic assumes /tmp/cs exists but doesn't validate if MVN_SELENIUM_VERSION is provided. If the build argument is empty or null, the fetch command could fail silently or produce unexpected results.

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/*
Error Handling

The RUN command combines multiple operations with && but lacks proper error handling. If the jar fetching fails, the build might continue with incomplete dependencies, potentially causing runtime issues.

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 link
Contributor

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
General
Remove misplaced CVE comment

The comment about patching CVE dependencies is misplaced and doesn't describe
the actual command being executed. Remove or relocate this comment to accurately
reflect what the command does.

Sessions/Dockerfile [15-24]

 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/*
  • Apply / Chat
Suggestion importance[1-10]: 4

__

Why: The suggestion correctly identifies a potentially confusing comment within the RUN command, and its removal improves the Dockerfile's clarity.

Low
  • More

@VietND96 VietND96 merged commit 1a151e3 into trunk Jul 27, 2025
28 checks passed
@VietND96 VietND96 deleted the sessions-dockerfile branch July 27, 2025 06:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant