Last active
August 5, 2024 20:07
-
-
Save beemi/f47a2829e7f85a2c6a841d1d43dc2ffb to your computer and use it in GitHub Desktop.
linux-chrome-driver-docker.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Use Ubuntu 22.04 as the base image | |
| FROM ubuntu:22.04 | |
| # Avoid prompts from apt | |
| ENV DEBIAN_FRONTEND=noninteractive | |
| # Set the ChromeDriver version | |
| ENV CHROMEDRIVER_VERSION=114.0.5735.90 | |
| # Install essential packages | |
| RUN apt update && apt install -y \ | |
| wget \ | |
| unzip \ | |
| openjdk-17-jdk \ | |
| maven \ | |
| xvfb \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Install Google Chrome | |
| RUN wget -q https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb \ | |
| && apt-get install -y --no-install-recommends ./google-chrome-stable_current_amd64.deb \ | |
| && rm google-chrome-stable_current_amd64.deb \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Install ChromeDriver | |
| RUN wget -q "https://chromedriver.storage.googleapis.com/${CHROMEDRIVER_VERSION}/chromedriver_linux64.zip" \ | |
| && unzip chromedriver_linux64.zip -d /usr/local/bin \ | |
| && rm chromedriver_linux64.zip \ | |
| && chmod +x /usr/local/bin/chromedriver | |
| # Set up a non-root user | |
| RUN useradd -m myuser | |
| USER myuser | |
| WORKDIR /home/myuser | |
| # Set up the display for Chrome | |
| ENV DISPLAY=:99 | |
| # Copy the entrypoint script | |
| COPY --chown=myuser:myuser entrypoint.sh /home/myuser/entrypoint.sh | |
| RUN chmod +x /home/myuser/entrypoint.sh | |
| ENTRYPOINT ["/home/myuser/entrypoint.sh"] | |
| # Default command (can be overridden) | |
| CMD ["mvn", "test"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment