Skip to content

Instantly share code, notes, and snippets.

@sosan
Last active January 20, 2023 23:50
Show Gist options
  • Save sosan/8f20ae95a09e3fb5fb5d6f908fb7dc3c to your computer and use it in GitHub Desktop.
Save sosan/8f20ae95a09e3fb5fb5d6f908fb7dc3c to your computer and use it in GitHub Desktop.
ubuntu 22.04 nodejs 19 cypress 12.3
# syntax=docker/dockerfile:1.4
FROM ubuntu:22.04
RUN apt-get update && \
apt-get install -y apt-transport-https curl
ENV DEBIAN_FRONTEND noninteractive
ENV TERM xterm
ENV npm_config_loglevel warn
ENV npm_config_unsafe_perm true
# "fake" dbus address to prevent errors
# https://github.com/SeleniumHQ/docker-selenium/issues/87
ENV DBUS_SESSION_BUS_ADDRESS=/dev/null
RUN curl -sL https://deb.nodesource.com/setup_19.x -o nodesource_setup.sh
RUN bash nodesource_setup.sh
RUN apt-get install -y nodejs
# Install latest NPM and Yarn
RUN npm install -g npm@latest
RUN npm install -g yarn@latest
# install additional native dependencies build tools
RUN apt-get install -y \
build-essential \
git \
unzip \
tzdata \
fonts-liberation \
libcurl4 \
libcurl3-gnutls \
libcurl3-nss \
xdg-utils \
wget \
# firefox dependencies
bzip2 \
# add codecs needed for video playback in firefox
# https://github.com/cypress-io/cypress-docker-images/issues/150
mplayer
# set your timezone
RUN ln -fs /usr/share/zoneinfo/UTC /etc/localtime
RUN dpkg-reconfigure --frontend noninteractive tzdata
RUN apt-get install -y \
libgtk2.0-0 \
libnotify-dev \
libgconf-2-4 \
libnss3 \
libxss1 \
libasound2 \
xvfb
# install libappindicator3-1 - not included with Debian 11
RUN wget --no-verbose -O /usr/src/libappindicator3-1_0.4.92-7_amd64.deb "http://ftp.us.debian.org/debian/pool/main/liba/libappindicator/libappindicator3-1_0.4.92-7_amd64.deb" && \
dpkg -i /usr/src/libappindicator3-1_0.4.92-7_amd64.deb ; \
apt-get install -f -y && \
rm -f /usr/src/libappindicator3-1_0.4.92-7_amd64.deb && \
rm -f nodesource_setup.sh
# install Chrome browser
RUN node -p "process.arch === 'arm64' ? 'Not downloading Chrome since we are on arm64: https://crbug.com/677140' : process.exit(1)" || \
(wget --no-verbose -O /usr/src/google-chrome-stable_current_amd64.deb "http://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/google-chrome-stable_105.0.5195.102-1_amd64.deb" && \
dpkg -i /usr/src/google-chrome-stable_current_amd64.deb ; \
apt-get install -f -y && \
rm -f /usr/src/google-chrome-stable_current_amd64.deb)
# install Firefox browser
RUN node -p "process.arch === 'arm64' ? 'Not downloading Firefox since we are on arm64: https://bugzilla.mozilla.org/show_bug.cgi?id=1678342' : process.exit(1)" || \
(wget --no-verbose -O /tmp/firefox.tar.bz2 https://download-installer.cdn.mozilla.net/pub/firefox/releases/104.0.1/linux-x86_64/en-US/firefox-104.0.1.tar.bz2 && \
tar -C /opt -xjf /tmp/firefox.tar.bz2 && \
rm /tmp/firefox.tar.bz2 && \
ln -fs /opt/firefox/firefox /usr/bin/firefox)
RUN npm install -g typescript \
&& npm install -g cypress \
&& (node -p "process.env.CI_XBUILD && process.arch === 'arm64' ? 'Skipping cypress verify on arm64 due to SIGSEGV.' : process.exit(1)" \
|| (cypress verify \
# Cypress cache and installed version
# should be in the root user's home folder
&& cypress cache path \
&& cypress cache list \
&& cypress info \
&& cypress version)) \
# give every user read access to the "/root" folder where the binary is cached
# we really only need to worry about the top folder, fortunately
&& ls -la /root \
&& chmod 755 /root \
# Show where Node loads required modules from
&& node -p 'module.paths' \
# should print Cypress version
# plus Electron and bundled Node versions
&& cypress version \
&& echo " node version: $(node -v) \n" \
"npm version: $(npm -v) \n" \
"yarn version: $(yarn -v) \n" \
"typescript version: $(tsc -v) \n" \
"debian version: $(cat /etc/debian_version) \n" \
"user: $(whoami) \n" \
"chrome: $(google-chrome --version || true) \n" \
"firefox: $(firefox --version || true) \n"
# clean up
RUN rm -rf /var/lib/apt/lists/* \
&& apt-get clean
ENTRYPOINT ["cypress", "run"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment