Skip to content

Instantly share code, notes, and snippets.

@trobrock
Created October 19, 2023 16:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trobrock/337a54097ca73db808e85aed341c80d1 to your computer and use it in GitHub Desktop.
Save trobrock/337a54097ca73db808e85aed341c80d1 to your computer and use it in GitHub Desktop.
Dockerfile
FROM ruby:3.2.2
# Set up the Chrome PPA
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
RUN echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list
# Update the package list and install chrome
RUN apt-get update -y
RUN apt-get install -y google-chrome-stable
# Set up Chromedriver Environment variables
ENV CHROMEDRIVER_DIR /chromedriver
RUN mkdir $CHROMEDRIVER_DIR
# Download and install Chromedriver
RUN export CHROME_VERSION="$(google-chrome --version | awk '{ print $3 }' | sed -r 's/\.[0-9]+$//')" \
&& export CHROMEDRIVER_URL=$(curl --silent https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json | jq -r "last(.versions[] | select(.version | startswith(\"$CHROME_VERSION\"))) | .downloads.chromedriver[] | select(.platform==\"linux64\") | .url") \
&& echo "Using chromedriver url: $CHROMEDRIVER_URL" \
&& wget -q --continue -P $CHROMEDRIVER_DIR "$CHROMEDRIVER_URL" \
&& unzip $CHROMEDRIVER_DIR/chromedriver* -d $CHROMEDRIVER_DIR
# Put Chromedriver into the PATH
ENV PATH "${CHROMEDRIVER_DIR}/chromedriver-linux64":$PATH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment