femtopixel / docker-google-lighthouse

Google Lighthouse - Docker Image
https://brands.jaymoulin.me/femtopixel/docker-google-lighthouse
MIT License
69 stars 23 forks source link

Runtime error encountered: EACCES: permission denied Still exist with already write right for the mounted volume #25

Closed rongjiLei closed 1 month ago

rongjiLei commented 2 years ago

It is no problem if I am running this docker image locally in windows. But meet the error when I do it in Jenkin pipeline I do looked at the old issue which report similar in 2018. but I tried the solution to chmod 777 to the mounted volume But it is still the same

The docker image version I am using "Labels": { "maintainer": "Jay MOULIN https://jaymoulin.me/femtopixel/docker-google-lighthouse http://twitter.com/MoulinJay", "version": "v9.5.0" }

Steps to reproduce the issue:

  1. Works fine if I run the same command locally in windows
  2. sh 'docker run --rm --shm-size=256m --name lighthouse -v /var/jenkins_home/workspace/Lighthouse/Report:/home/chrome/reports --cap-add=SYS_ADMIN femtopixel/google-lighthouse https://websiteUrl --preset=desktop --output html --output-path=lighthouse-result.html'
  3. Console logs

    Fri, 08 Apr 2022 16:14:21 GMT LH:status Generating results... Fri, 08 Apr 2022 16:14:21 GMT LH:ChromeLauncher Killing Chrome instance 27 Runtime error encountered: EACCES: permission denied, open 'lighthouse-result.html' Error: EACCES: permission denied, open 'lighthouse-result.html' [Pipeline] } [Pipeline] // stage [Pipeline] } [Pipeline] // node [Pipeline] End of Pipeline ERROR: script returned exit code 1 Finished: FAILURE

kevinbreit commented 2 months ago

I picked up an similar error:

Runtime error encountered: EACCES: permission denied, open '/home/chrome/reports/lighthouse-report-mobile.json' Error: EACCES: permission denied, open '/home/chrome/reports/lighthouse-report-mobile.json'

I found the error in the FAQ but the provided solution did not fix the error. \ After some research I discovered the flag --disable-dev-shm-usage in this StackOverflow-post, which fixed the issue for me. \ This also has a related chrome bug: https://issues.chromium.org/issues/40517415

It was important to have the correct permissions from the FAQ and the flag enabled.

My whole command looks like the following:

SITE_URL=$1 # get the parameter
OUTPUT_DIR="$(pwd)/.ddev/reports" # target directory to save the files to
# we need --disable-dev-shm-usage because of chrome bug: https://issues.chromium.org/issues/40517415
CHROME_FLAGS="--headless --disable-gpu --no-sandbox --ignore-certificate-errors --disable-dev-shm-usage --allow-insecure-localhost --silent"

# Run Lighthouse for mobile
docker run --privileged --rm --name lighthouse-mobile \
  --network host \
  -v "$OUTPUT_DIR:/home/chrome/reports" \
  -e CHROME_FLAGS="$CHROME_FLAGS" \
  femtopixel/google-lighthouse "$SITE_URL" \
  --output json \
  --output-path "/home/chrome/reports/lighthouse-report-mobile.json" \
  --form-factor mobile \
  --screenEmulation.mobile \
  --screenEmulation.width=360 \
  --screenEmulation.height=640 \
  --screenEmulation.deviceScaleFactor=2 \
  --ignore-certificate-errors \
  --disable-dev-shm-usage \
  --allow-insecure-localhost \
  --quiet

Hope I was able to help.