Lighthouse Container

⛯ A container to run Google Lighthouse tests.

Usage

Basic Usage

$ docker run --rm \
     docker.io/lowcloudnine/lighthouse:3.0.0 \
     --category best-practices \
     --url https://www.python.org
83
$ docker run --rm \
     -v /home/wodan:/workspace \
     docker.io/lowcloudnine/lighthouse:3.0.0 \
     -c accessibility \
     -u https://www.python.org \
     --report
lighthouse_accessibility_20220708_2302.html

Getting Help

The container can be run with help flags (–help or -h) and outputs help in a format familiar to linux shell users.

$ docker run --rm \
    docker.io/lowcloudnine/lighthouse:3.0.0 \
    --help
usage: docker run [various docker options] lighthouse [-h]
                                                      [--category {accessibility,best-practices,performance,pwa,seo}]
                                                      [--url URL] [--report]
                                                      [--verbose]

Run Google Lighthouse inside a docker container with some options.

optional arguments:
  -h, --help            show this help message and exit
  --category {accessibility,best-practices,performance,pwa,seo}, -c {accessibility,best-practices,performance,pwa,seo}
                        The category/type of test to run, defaults to
                        accessibility.
  --url URL, -u URL     A valid URL to a web site to test must start with a
                        valid protocol of http:// or https://. Defaults to
                        https://www.python.org
  --report, -r          Generate/workspace the full HTML report to a file. If
                        this flag/option is set only the html file will be
                        generated in the directory mounted with the docker
                        volume flag, i.e. -v /home/user/reports:/workspace as
                        output.html. If the flag is not given a single number,
                        the result of the given test which is between 0 and
                        100 will be piped to stdout.
  --verbose, -v         Generate more verbose output.

Verbose

If you are working on improving the image/container or you just want to see more output the verbose flag might be helpful.

$ # for the score output
$ docker run --rm \
    docker.io/lowcloudnine/lighthouse:3.0.0 --verbose
----------------------------------------
All arguments given: Namespace(category='accessibility', report=False, url='https://www.python.org', verbose=True)

Category: accessibility
URL: https://www.python.org
Report: False
Verbose: True

Score:
78
----------------------------------------
$ # ... or for the report output
$ docker run --rm \
    docker.io/lowcloudnine/lighthouse:3.0.0 --verbose --report
----------------------------------------
All arguments given: Namespace(category='accessibility', report=True, url='https://www.python.org', verbose=True)

Category: accessibility
URL: https://www.python.org
Report: True
Verbose: True

Output file:
lighthouse_accessibility_20220708_2302.html
----------------------------------------

Please see the full documentation and/or visit the GitHub repository.

Overview

An OCI compliant image available on docker hub to run Google Lighthouse tests against a given URL. It can be used to generate a single score or output the HTML file. The goal is to provide a tool that can be used in CI/CD pipelines to ensure any front-end product achieves a given level and doesn’t regress.

Acknowledgements

Thank you to Raoul du Plessis for open sourcing the image of the lighthouse used on this site. The fav-icon for the site is provided by flaticon.

Indices and tables

Change Log

3.0.0 2022-07-08 Changes base to ubi8-minimal

  • Based on the fix in 2.2.1 to latest image and reading security reports, changed the base image to ubi8-minimal:latest to reduce vulnerabilities and reduced the container size to 1.05GB

  • Added an ENV for USER and then updated the appropriate places in the Dockerfile

  • Updated the documentation with the new version numbers and added tagging instructions as a latest version was added to docker hub

2.2.1 2022-07-08 Changed base to latest

  • Based on a recommendation from Snyk, changed the base container image to latest

2.2.0 2022-05-03 More explicit entrypoint

  • Dockerfile has more explicit code pointing to the entrypoint with notes about why it was done that way

  • entrypoint.py get the output directory from the environment as it’s provided by the Dockerfile

  • Verbose is now actually more verbose and provides semi-useful information

  • Updated README with more examples such as using the –help flag

2.1.0 2022-05-03 Better file names for output

  • Refactored entrypoint.py to:
    • output file names with dates and times in them

    • create LighthouseTest class to easy working with tests

    • ran entrypoint through black and pylint

  • Added ARG to Dockerfile for the output/workspace directory

  • Updated documentation with the changes

2.0.1 2022-04-27 Add documentation

  • Add sphinx generated documentation

  • In documentation show how to deploy to github pages

2.0.0 2022-04-19 Better Argument Handling

  • Refactor to use argparse library for argument handling

1.0.0 2022-04-12 Initial release

  • Initial release, container size 882MB