GoogleChrome / lighthouse-ci

Automate running Lighthouse for every commit, viewing the changes, and preventing regressions
Apache License 2.0
6.34k stars 635 forks source link

Add ability to run server in Docker with a custom config #889

Open DeniDoman opened 1 year ago

DeniDoman commented 1 year ago

Is your feature request related to a problem? Please describe. I want to use your Docker image for lhci-server, but I can't find a way to use my custom configuration file. The config file is hardcoded in a package.json file:

  "scripts": {
    "start": "lhci server --config=./lighthouserc.json"
  },

Describe the solution you'd like Solution is pretty simple - use environment variable to allow user to set a path to the configuration file, with a fallback to the default one:

  "scripts": {
    "start": "lhci server --config=${CONFIG_PATH:-./lighthouserc.json}"
  }

It allow to run Docker container in the following way:

docker container run -e CONFIG_PATH=/data/lighthouserc.json -p 9001:9001 -v lhci-data:/data' -d patrickhulce/lhci-server

Describe alternatives you've considered There is a workaround with Environment variables, but when you need to setup more than 5 - it became messy.

DeniDoman commented 1 year ago

If you ok with it - I'll raise a PR. My only concern with the proposed solution - is a compatibility with different operation systems, I'm not a very experienced here.