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

fix: install dependencies for websockify utils in novnc #2443

Merged
merged 1 commit into from
Oct 25, 2024
Merged

Conversation

VietND96
Copy link
Member

@VietND96 VietND96 commented Oct 25, 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

Fixes #2438
Fixes #2416

Warning: could not find self.pem
The path /opt/bin/noVNC/utils/websockify exists, but /opt/bin/noVNC/utils/websockify/run either does not exist or is not executable.
If you intended to use an installed websockify package, please remove /opt/bin/noVNC/utils/websockify.

seluser@887b879fb410:/$ /opt/bin/noVNC/utils/websockify/run
/opt/bin/noVNC/utils/websockify/websockify/websocket.py:31: UserWarning: no 'numpy' module, HyBi protocol will be slower
warnings.warn("no 'numpy' module, HyBi protocol will be slower")
Usage:
main.py [options] [source_addr:]source_port target_addr:target_port
main.py [options] --token-plugin=CLASS [source_addr:]source_port
main.py [options] --unix-target=FILE [source_addr:]source_port
main.py [options] [source_addr:]source_port -- WRAP_COMMAND_LINE

main.py: error: Too few arguments
  • Add step to setup dependencies needed in websockify
  • Move /websockify and run executable file to right directory, instead of nested folder.

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

Bug fix, Enhancement


Description

  • Added python3-pip installation to the Base Dockerfile to ensure necessary Python packages can be installed.
  • Enhanced the NodeBase Dockerfile by installing and upgrading setuptools and setting up dependencies for websockify.
  • Moved websockify files to the correct directory and set executable permissions.
  • Cleaned up unnecessary files after setting up websockify to reduce image size.

Changes walkthrough 📝

Relevant files
Dependencies
Dockerfile
Add python3-pip installation to Base Dockerfile                   

Base/Dockerfile

  • Added installation of python3-pip.
  • Ensured compatibility with ARM architecture.
  • +1/-0     
    Enhancement
    Dockerfile
    Install and configure websockify dependencies in NodeBase Dockerfile

    NodeBase/Dockerfile

  • Installed and upgraded setuptools using pip.
  • Set up dependencies for websockify.
  • Moved and set permissions for websockify files.
  • Cleaned up unnecessary files post-installation.
  • +10/-2   

    💡 PR-Agent usage: Comment /help "your question" on any pull request to receive relevant information

    Copy link

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    🎫 Ticket compliance analysis 🔶

    2438 - Partially compliant

    Fully compliant requirements:

    • Fix the issue where docker-selenium does not start correctly due to exit of novnc on openEuler

    Not compliant requirements:

    2416 - Fully compliant

    Fully compliant requirements:

    • Fix the issue where noVNC does not start due to malfunctioning -x check
    • Ensure the /opt/bin/noVNC/utils/websockify/run file is executable
    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Potential Dependency Conflict
    The use of --break-system-packages flag when installing setuptools might lead to system-wide package conflicts. Consider using a virtual environment or container-specific package management strategy.

    File Permissions
    Verify that the permissions set for the websockify files are appropriate and secure, especially for the run executable.

    Copy link

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    Performance
    Implement multi-stage builds to optimize the final image size

    Consider using multi-stage builds to reduce the final image size. You can have a
    build stage for compiling and installing dependencies, and a final stage that only
    copies the necessary files.

    NodeBase/Dockerfile [123-130]

     && python3 setup.py install \
    -# Move websockify and run to the noVNC directory
    -&& mv websockify /opt/bin/noVNC/utils/websockify \
    -&& mv run /opt/bin/noVNC/utils/websockify \
    +# Move only necessary files to the final image
    +&& mkdir -p /opt/bin/noVNC/utils/websockify \
    +&& cp -r websockify /opt/bin/noVNC/utils/ \
    +&& cp run /opt/bin/noVNC/utils/websockify/ \
     && chmod +x /opt/bin/noVNC/utils/websockify/run \
     # Cleanup unnecessary files
     && cd .. \
     && rm -rf websockify-${WEBSOCKIFY_VERSION} \
    • Apply this suggestion
    Suggestion importance[1-10]: 7

    Why: Multi-stage builds can significantly reduce the final image size by only including necessary files, which is beneficial for performance and efficiency. This suggestion is relevant and can enhance the Dockerfile's effectiveness.

    7
    Use --no-install-recommends flag with apt-get to reduce image size

    Consider using the --no-install-recommends flag with apt-get install to avoid
    installing unnecessary packages, which can help reduce the image size.

    NodeBase/Dockerfile [102-106]

     && locale-gen ${LANGUAGE} \
     && dpkg-reconfigure --frontend noninteractive locales \
     && apt-get -qyy autoremove \
    +&& apt-get -qyy clean \
     && rm -rf /var/lib/apt/lists/* \
    -&& apt-get -qyy clean \
    • Apply this suggestion
    Suggestion importance[1-10]: 6

    Why: The --no-install-recommends flag can help reduce the image size by avoiding unnecessary packages. This is a useful optimization, though its impact may vary depending on the specific packages involved.

    6
    Best practice
    Use a requirements.txt file for managing Python dependencies

    Consider using a requirements.txt file for managing Python dependencies instead of
    installing them directly in the Dockerfile. This approach is more maintainable and
    allows for easier version control of dependencies.

    NodeBase/Dockerfile [107-111]

     && pip install --no-cache-dir --upgrade --break-system-packages setuptools \
    +&& pip install --no-cache-dir --break-system-packages -r requirements.txt \
     ########################################
     # noVNC exposes VNC through a web page #
     ########################################
     && wget -nv -O noVNC.zip \
    • Apply this suggestion
    Suggestion importance[1-10]: 5

    Why: Using a requirements.txt file can improve maintainability and version control of dependencies. However, this suggestion requires additional setup and may not be necessary for a single dependency, so its impact is moderate.

    5

    💡 Need additional feedback ? start a PR chat

    @VietND96 VietND96 merged commit a5e252c into trunk Oct 25, 2024
    47 of 52 checks passed
    @VietND96 VietND96 deleted the fix-novnc branch October 25, 2024 07:01
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    1 participant