Skip to content

Instantly share code, notes, and snippets.

@dennismclaugh

dennismclaugh/dockerfile

Last active Jan 17, 2020
Embed
What would you like to do?
Dockerfile based on Alpine Linux complete with Ruby, Watir Webdriver, Shopify API, Chrome, and Firefox. https://www.dennismclaughlin.tech/build-docker-image-ruby-watir-webdriver-shopify-and-chrome/
FROM alpine:latest
# Point to specific Alpine Package repositories for Chromium and Firefox.
RUN apk update && apk upgrade \
&& echo @latest-stable http://nl.alpinelinux.org/alpine/latest-stable/community >> /etc/apk/repositories \
&& echo @latest-stable http://nl.alpinelinux.org/alpine/latest-stable/main >> /etc/apk/repositories \
&& echo @edge-testing http://dl-cdn.alpinelinux.org/alpine/edge/testing >> /etc/apk/repositories \
&& echo @edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main >> /etc/apk/repositories
# Install Ruby dev environment
RUN apk add --no-cache build-base libffi-dev ruby-dev ruby-rdoc ruby-webrick@latest-stable zlib-dev
# Install Chromium
RUN apk add --no-cache chromium-chromedriver chromium@latest-stable harfbuzz@latest-stable nss@latest-stable
# Install Firefox and the Gechodriver
RUN apk add --no-cache icu-libs@edge-main firefox@edge-testing
RUN wget https://github.com/mozilla/geckodriver/releases/download/v0.24.0/geckodriver-v0.24.0-linux64.tar.gz && \
tar -zxvf geckodriver-v0.24.0-linux64.tar.gz && \
mv ./geckodriver /usr/local/bin/ && \
chmod a+x /usr/local/bin/geckodriver
# Install Ruby gems required by the test framework.
RUN gem install rake minitest minitest-reporters watir:6.16 shopify_api bigdecimal aws-sdk-s3
# Clean up leftovers to help keep the final image small.
RUN rm -rf /var/lib/apt/lists/* \
/var/cache/apk/* \
/usr/share/man \
/tmp/*
# Copy the automated tests into the container.
ADD . webdriver-tests
# Add 'webdriver' as a user
RUN adduser -D webdriver \
&& chown -R webdriver:webdriver /webdriver-tests
# Switch to non-privileged user 'webdriver'
USER webdriver
WORKDIR /webdriver-tests
# Set the environment variables for the Chromium browser.
ENV CHROME_BIN=/usr/bin/chromium-browser \
CHROME_PATH=/usr/lib/chromium/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment