Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(docker): include globally installed puppeteer #736

Merged
merged 8 commits into from
Nov 14, 2022

Conversation

Eliasvdb
Copy link
Contributor

@Eliasvdb Eliasvdb commented Jan 6, 2022

I noticed puppeteer was not included in the lhci-client docker image. I altered the Dockerfile to include a global npm install of puppeteer. I set the ENV var PUPPETEER_SKIP_DOWNLOAD=true, because otherwise the puppeteer install will try to download chromium (but it will not have permission). As far as I tested this chrmium step is not needed as the docker image itself contains google-chrome-stable.

@Eliasvdb
Copy link
Contributor Author

Eliasvdb commented Jan 6, 2022

cc @patrickhulce

@Eliasvdb
Copy link
Contributor Author

Eliasvdb commented Jan 6, 2022

I just signed my CLA, but maybe it needs some time to process. That check should be green soon I guess.

Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @Eliasvdb!

@@ -14,6 +17,9 @@ RUN apt-get update \
RUN npm install -g @lhci/[email protected]
RUN npm install -g lighthouse

# Install puppeteer
RUN npm install -g puppeteer
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you'll need to add this after the next RUN block or it won't be available

RUN cd /home/lhci/reports && npm link puppeteer

Copy link
Collaborator

@patrickhulce patrickhulce Jan 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can test it out with a script in scripts/foo.js and running docker run -v "$(pwd)/lhci-data:/home/lhci/reports/.lighthouseci" -v "$(pwd)/scripts:/home/lhci/reports/scripts" lhci-client lhci collect --puppeteerScript=scripts/foo.js --url=https://example.com

@Eliasvdb
Copy link
Contributor Author

@patrickhulce I added the changes you suggested. I am unable to test it locally with your command though. When I build the docker image and run docker run -v "$(pwd)/lhci-data:/home/lhci/reports/.lighthouseci" -v "$(pwd)/scripts:/home/lhci/reports/scripts" lhci-client lhci collect --puppeteerScript=scripts/puppeteer-test.js --url=https://example.com from project root, I get the following error:

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


TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md

    at onClose (/usr/local/lib/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:229:20)
    at ChildProcess.<anonymous> (/usr/local/lib/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:220:79)
    at ChildProcess.emit (events.js:326:22)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:276:12)

I tried setting --puppeteerLaunchOptions, like so: docker run -v "$(pwd)/lhci-data:/home/lhci/reports/.lighthouseci" -v "$(pwd)/scripts:/home/lhci/reports/scripts" lhci-client lhci collect --puppeteerScript=scripts/puppeteer-test.js --puppeteerLaunchOptions="{'args':['--no-sandbox', '--disable-setuid-sandbox']}" --url=https://example.com, but that isn't working either (same error), am I setting them correctly?

@patrickhulce
Copy link
Collaborator

but that isn't working either (same error), am I setting them correctly?

No puppeteerLaunchOptions isn't parsed as a string. I would expect --puppeteerLaunchOptions.args=--no-sandbox --puppeteerLaunchOptions.args=--disable-setuid-sandbox to work though.

@Eliasvdb
Copy link
Contributor Author

Eliasvdb commented Feb 10, 2022

I would expect --puppeteerLaunchOptions.args=--no-sandbox --puppeteerLaunchOptions.args=--disable-setuid-sandbox to work though

Ah yes, that's it! Seems to work correctly then. Whenever a puppeteerscript is provided it seems puppeteer will need to be launched with both those options though. Should those be configured somewhere then instead of leaving it up to the user to specify them? What do you think?

Let me know if you would like to see anything changed, I'll make sure to fix it sooner this time 😃

Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @Eliasvdb! 🎉

@patrickhulce
Copy link
Collaborator

Should those be configured somewhere then instead of leaving it up to the user to specify them? What do you think?

Nah, let's just add a doc example of how to properly invoke it 👍

CLA issues + an example in the docs and I think we're good to go 🎉

@Eliasvdb
Copy link
Contributor Author

Eliasvdb commented Feb 10, 2022

Nah, let's just add a doc example of how to properly invoke it 👍

I'll make sure to add it!

CLA issues + an example in the docs and I think we're good to go 🎉

I'm not sure what the problem is, I have signed the CLA with my GitHub username 🤔

@Eliasvdb
Copy link
Contributor Author

I added the info to the documentation.

Now I only need to figure out why my CLA is seen as missing...

@Eliasvdb Eliasvdb force-pushed the lhci-client-docker-puppeteer branch from 759ee52 to 404f853 Compare February 11, 2022 09:15
@Eliasvdb
Copy link
Contributor Author

@patrickhulce Found and solved the CLA issue! If there's anything else, let me know!

@Eliasvdb
Copy link
Contributor Author

Those failing tests seem unrelated to my change, does it happen more often? Seems timeout related?

@patrickhulce
Copy link
Collaborator

They probably are, there are quite a few flakes.

@connorjclark connorjclark changed the title Added global npm install for puppeteer to the lhci client Dockerfile fix(docker): include globally installed puppeteer Sep 13, 2022
@Djiit
Copy link
Contributor

Djiit commented Nov 10, 2022

Hey team, are we still planning on merging this ? Thanks 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants