Skip to content
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

build: support download older Chrome version #2216

Merged
merged 1 commit into from
Apr 19, 2024
Merged

Conversation

VietND96
Copy link
Member

@VietND96 VietND96 commented Apr 18, 2024

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

Motivation and Context

Support downloading specific Chrom version from Official Site & Installing

E.g: given --build-arg CHROME_VERSION=google-chrome-stable_119.0.6045.159-1

Find list versions are available at https://www.ubuntuupdates.org/package/google_chrome/stable/main/base/google-chrome-stable

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.

Type

Enhancement


Description

  • Added support for downloading and installing specific versions of Google Chrome in the Dockerfile for NodeChrome.
  • Introduced a new build argument TARGETARCH to specify the architecture for the Chrome version to be downloaded.
  • Implemented conditional logic to handle different installation paths based on the provided CHROME_VERSION.
  • This enhancement allows for more flexibility in using different versions of Chrome for testing environments.

Changes walkthrough

Relevant files
Enhancement
Dockerfile
Support for downloading specific Chrome versions based on build
arguments

NodeChrome/Dockerfile

  • Added a new build argument TARGETARCH to specify the architecture.
  • Modified the installation process to support downloading specific
    versions of Chrome based on the CHROME_VERSION argument.
  • Added conditional logic to handle the download and installation of a
    specified Chrome version if it matches a specific pattern.
  • Cleaned up the installation by removing the downloaded .deb file.
  • +9/-2     

    PR-Agent usage:
    Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    E.g: given --build-arg CHROME_VERSION=google-chrome-stable_119.0.6045.159-1
    
    Find list versions at https://www.ubuntuupdates.org/package/google_chrome/stable/main/base/google-chrome-stable
    
    Signed-off-by: Viet Nguyen Duc <[email protected]>
    @VietND96 VietND96 requested a review from diemol April 18, 2024 16:18
    Copy link

    PR Description updated to latest commit (470a0c5)

    Copy link

    PR Review

    ⏱️ Estimated effort to review [1-5]

    2, because the changes are focused on a single Dockerfile with a clear purpose of supporting specific Chrome version downloads. The logic is straightforward, involving conditional installation based on the provided Chrome version.

    🧪 Relevant tests

    No

    🔍 Possible issues

    Possible Bug: The conditional check for the Chrome version format might not correctly handle edge cases or unexpected version formats, leading to failed downloads or installations.

    Error Handling: There is no explicit error handling if the wget command fails to download the specified Chrome version, which could lead to a broken build process without clear error messages.

    🔒 Security concerns

    No


    ✨ Review tool usage guide:

    Overview:
    The review tool scans the PR code changes, and generates a PR review which includes several types of feedbacks, such as possible PR issues, security threats and relevant test in the PR. More feedbacks can be added by configuring the tool.

    The tool can be triggered automatically every time a new PR is opened, or can be invoked manually by commenting on any PR.

    • When commenting, to edit configurations related to the review tool (pr_reviewer section), use the following template:
    /review --pr_reviewer.some_config1=... --pr_reviewer.some_config2=...
    
    [pr_reviewer]
    some_config1=...
    some_config2=...
    

    See the review usage page for a comprehensive guide on using this tool.

    Copy link

    PR Code Suggestions

    CategorySuggestions                                                                                                                                                       
    Enhancement
    Reduce Docker image size by minimizing unnecessary package installations.

    Consider adding --no-install-recommends to the apt-get update command to minimize the
    installation of unnecessary packages, which can help reduce the overall size of the Docker
    image.

    NodeChrome/Dockerfile [21]

    -&& apt-get update -qqy \
    +&& apt-get update -qqy --no-install-recommends \
     
    Reliability
    Ensure the build process stops if the Chrome package download fails.

    Add error handling for the wget command to ensure that the build process stops if the
    download of the Chrome package fails. This can be achieved by using set -e at the
    beginning of the RUN instruction.

    NodeChrome/Dockerfile [24]

    -wget -qO google-chrome.deb "https://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/${CHROME_VERSION}_${TARGETARCH}.deb" \
    +set -e && wget -qO google-chrome.deb "https://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/${CHROME_VERSION}_${TARGETARCH}.deb" \
     
    Best practice
    Ensure non-interactive installations during Docker builds.

    Use apt-get install -y to automatically answer 'yes' to prompts during the installation
    process, ensuring that the Docker build does not stall waiting for user input.

    NodeChrome/Dockerfile [28]

    -&& apt-get -qqy --no-install-recommends install ${CHROME_VERSION} ; \
    +&& apt-get -qqy --no-install-recommends install -y ${CHROME_VERSION} ; \
     
    Security
    Verify the integrity and authenticity of the downloaded Chrome package before installation.

    Consider verifying the downloaded .deb file with dpkg -i before installing it. This adds a
    layer of security by ensuring the integrity and authenticity of the package.

    NodeChrome/Dockerfile [25]

    -&& apt-get -qqy --no-install-recommends install --allow-downgrades ./google-chrome.deb \
    +&& dpkg -i ./google-chrome.deb && apt-get -qqy --no-install-recommends install --allow-downgrades ./google-chrome.deb \
     
    Maintainability
    Reduce Docker image size by removing unnecessary files after installation.

    Add cleanup commands after installing Chrome to remove unnecessary files and reduce the
    Docker image size. This includes clearing out the apt cache and removing temporary files.

    NodeChrome/Dockerfile [31]

    -&& rm -rf /var/lib/apt/lists/* /var/cache/apt/*
    +&& apt-get clean && rm -rf /var/lib/apt/lists/* /var/cache/apt/* /tmp/* /var/tmp/*
     

    ✨ Improve tool usage guide:

    Overview:
    The improve tool scans the PR code changes, and automatically generates suggestions for improving the PR code. The tool can be triggered automatically every time a new PR is opened, or can be invoked manually by commenting on a PR.

    • When commenting, to edit configurations related to the improve tool (pr_code_suggestions section), use the following template:
    /improve --pr_code_suggestions.some_config1=... --pr_code_suggestions.some_config2=...
    
    [pr_code_suggestions]
    some_config1=...
    some_config2=...
    

    See the improve usage page for a comprehensive guide on using this tool.

    @VietND96 VietND96 merged commit 4eb816a into SeleniumHQ:trunk Apr 19, 2024
    12 checks passed
    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.

    2 participants