【问题标题】:Lighthouse in GitLab CIGitLab CI 中的灯塔
【发布时间】:2023-12-25 13:43:02
【问题描述】:

我正在尝试使用 GitLab CI 中的 Lighthouse 在部署后对远程网站运行扫描。作业不断抛出错误。

我的工作配置如下:

lighthouse:
  stage: scan
  image: markhobson/node-chrome
  script:
    - npm install -g lighthouse lighthouse-plugin-field-performance --unsafe-perm
    - lighthouse $URL --plugins=lighthouse-plugin-field-performance --chrome-flags=”--headless --no-sandbox” --verbose 

我也试过image: buildkite/puppeteer。在这两种情况下,当我尝试调用 Lighthouse 时都会遇到类似的错误,如下所示:

Wed, 09 Oct 2019 20:22:42 GMT ChromeLauncher:verbose created /tmp/lighthouse.KXhqWF0
Wed, 09 Oct 2019 20:22:42 GMT ChromeLauncher:verbose Launching with command:
"/usr/bin/google-chrome-stable" --disable-translate --disable-extensions --disable-background-networking --disable-sync --metrics-recording-only --disable-default-apps --mute-audio --no-first-run --remote-debugging-port=44495 --disable-setuid-sandbox --user-data-dir=/tmp/lighthouse.KXhqWF0 about:blank
Wed, 09 Oct 2019 20:22:42 GMT ChromeLauncher:verbose Chrome running with pid 36 on port 44495.
Wed, 09 Oct 2019 20:22:42 GMT ChromeLauncher Waiting for browser.
Wed, 09 Oct 2019 20:22:42 GMT ChromeLauncher Waiting for browser...
Wed, 09 Oct 2019 20:22:43 GMT ChromeLauncher Waiting for browser.....
Wed, 09 Oct 2019 20:22:43 GMT ChromeLauncher Waiting for browser.......
Wed, 09 Oct 2019 20:22:44 GMT ChromeLauncher Waiting for browser.........
Wed, 09 Oct 2019 20:22:44 GMT ChromeLauncher Waiting for browser...........

Wed, 09 Oct 2019 20:23:07 GMT ChromeLauncher:error connect ECONNREFUSED 127.0.0.1:44495
Wed, 09 Oct 2019 20:23:07 GMT ChromeLauncher:error Logging contents of /tmp/lighthouse.KXhqWF0/chrome-err.log
Wed, 09 Oct 2019 20:23:07 GMT ChromeLauncher:error 
(google-chrome-stable:36): Gtk-WARNING **: cannot open display: 
[1009/202244.656645:ERROR:nacl_helper_linux.cc(310)] NaCl helper process running without a sandbox!
Most likely you need to configure your SUID sandbox correctly

Unable to connect to Chrome

我不完全确定此时我需要做什么。我在质疑是否尝试更基本的节点映像并尝试手动安装我需要的东西,我最初尝试过,发现使用 Lighthouse 管理 Chrome/Chromium 并不像我想要的那么简单。有什么想法或建议吗?

【问题讨论】:

    标签: docker gitlab-ci google-chrome-headless lighthouse


    【解决方案1】:

    您可以尝试使用此图像,该图像已安装好所有东西以执行报告https://hub.docker.com/r/femtopixel/google-lighthouse/

    【讨论】: