I have tried running a docker image, that previously worked on a non-M1 platform, to run nightwatch tests using Chromedriver and chromium. When I switched to an M1 mac, the first assertion of the test would fail, which implied that Chrome wasn't even starting up in the first place. I tried Chromium and google-chrome-stable, both of which had the same failure. I also tried running a VNC server inside of the docker container to see what is going on. When I got in and tried to start chrome, nothing happened. When I tried to start Chromium I got a message that it is not supported on the current hardware.
This is how I build my docker container :
FROM node:10-buster-slim
WORKDIR /home/node
# Installing some missing but critical items:
# Chromium info: https://www.chromium.org/
RUN \
apt-get update && \
useradd apps && \
mkdir -p /home/apps && \
chown apps:apps /home/apps && \
apt-get install -y \
libglib2.0-0 \
libnss3 \
libx11-6 \
wget \
x11vnc \
xvfb \
fluxbox \
wmctrl \
gnupg2 && \
apt-get clean && \
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \
echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list && \
apt-get update && apt-get -y install google-chrome-stable
COPY docker-startup.sh /
RUN chmod 777 /docker-startup.sh
CMD '/docker-startup.sh'
# Copy only package.json and package-lock to start.
# Allows packages to to be cached in Docker layers, preventing the need to
# repeatedly re-install packages for any update to ui-tests.
COPY package.json package-lock.json ./
# Install testing dependencies (Nightwatch, Chromedriver)
# Use npm ci to install using package-lock.json, and not replace its contents.
# FYI: npm i chromedriver uses the version # from package.json
RUN \
npm ci && \
npm i -g [email protected] && \
npm i -g chromedriver@latest --unsafe-perm=true --allow-root
# Copies code over to the default working directory:
# The below COPY assumes you are copying /ui-tests to /ui-tests
COPY . .
# Sets variable used in Nightwatch Reporter:
ENV TEST_ENV=docker
ENV TERM=xterm-256color
# Resolves socket error / ECON reset
ENV DBUS_SESSION_BUS_ADDRESS=/dev/null
There is a .sh
script called docker-startup.sh
that just sets up and runs the VNC server for me to be able to see what is going on, that is not too important in this case.
The command used to run the docker container is this
docker run --privileged -p 5900:5900 --user apps -e VNC_SERVER_PASSWORD=password --platform linux/amd64 -e APPBRANCH=$(git rev-parse --abbrev-ref HEAD) -v ~/work/dev/services/beast-portal/ui-tests/screenshots:/home/node/screenshots -v ~/work/dev/services/beast-portal/ui-tests/reports:/home/node/reports --env-file ./nightwatch.env nightwatch:stable nightwatch --env {--EnvironmentToTestIn--} --test {--TestToRun--.js}
This runs the docker container and then runs the nightwatch test with a given environment and a given test file.
The command used to build the docker file is this :
cd ~/work/dev/services/beast-portal/ui-tests && docker build --platform linux/amd64 -t \"nightwatch:stable\" .
I have also tried messing with the versions of Chromedriver and nightwatch but that still gave the same error where it fails to verify the first assertion as chrome isn't even started from the looks of it. This feels like an M1 architecture issue but I can't figure it out.