garris / BackstopJS

Catch CSS curve balls.
http://backstopjs.org
MIT License
6.67k stars 605 forks source link

Cannot pass engine-options in backstopJS config file #1447

Open MichaelVanhoutte1 opened 1 year ago

MichaelVanhoutte1 commented 1 year ago

I'm trying to run headless chrome in an Alpine docker container to run tests with BackstopJS. I'm giving the --no-sandbox and '--disable-setuid-sandbox' arguments to puppeteer but it's still giving me this error when running from root:

Running as root without --no-sandbox is not supported.

or when running as non-root user:

Failed to move to new namespace: PID namespaces supported, Network namespace supported, but failed: errno = Operation not permitted

I'm not sure what i could be doing wrong since I'm giving the correct arguments to my backstopJS config.

BackstopJS config:

...
engine: 'puppet',
  engineOptions: {
    headless: true,
    args: ['--no-sandbox', '--disable-setuid-sandbox'],
  },
...

Dockerfile:

FROM node:14.17.1-alpine

VOLUME /var/www
WORKDIR /var/www

RUN apk update && apk add --no-cache git openssh curl chromium
RUN yarn global add bower
RUN yarn global add ember-cli

COPY install.sh /root/
RUN chmod u+x /root/install.sh

COPY fix-uid.sh /root/
RUN chmod u+x /root/fix-uid.sh && /root/fix-uid.sh
RUN ln -s /usr/bin/chromium-browser /usr/bin/chrome

RUN apk add --no-cache \
    chromium \
    nss \
    freetype \
    harfbuzz \
    ca-certificates \
    ttf-freefont \
    nodejs \
    yarn
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true \
    PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser

RUN yarn add puppeteer@13.5.0

CMD ember s
garris commented 1 year ago

There was a bad commit in 6.1.4 -- does this work for you in 6.1.3?

garris commented 1 year ago

@MichaelVanhoutte1 👆

MichaelVanhoutte1 commented 1 year ago

@garris I've switched it to 6.1.3 but it still doesn't work. I've even forked the repo and manually added the setting in there and that didn't change anything either. Any clue as to what this might be?

garris commented 1 year ago

There is a sanity check in the docs -- installs a fresh backstop and runs a test.

mkdir backstopSanityTest; cd backstopSanityTest; npm install backstopjs; ./node_modules/.bin/backstop init; ./node_modules/.bin/backstop test

Maybe just try to use this locally on your computer. If backstop successfully runs then just create a simple docker image and run that in your container. This might help narrow down what is going on. I am not a container expert so I don't have any fancy advice other than just try to keep scoping the problem down till you isolate the blocker.

Also: I am not sure the issue is about passing engine options -- haven't had a chance to confirm this yet.

MichaelVanhoutte1 commented 1 year ago

I also don't think the issue is just about this. I've been diving deeper into it and have passed the engine options directly to the engine or even directly to the instance of chromium. This gave me a new error but didn't fix my problem. I do believe I'll just have to try to scope the issue here and see where the problem truly lies. I'll definitely try out your advice though. Thanks already!