Website performance is one of those things that is “important” to everyone but it is sometime hard to test and keep track of the results in a way that is easy to navigate and doesn’t require too much effort. Recently it has become even more important for SEO (Search Engine Optimization) with the big search engines starting to use these metrics more to affect ranking (See: Understanding page experience in Google Search results).
Google Lighthouse is a well known performance testing tool for websites that is built into Google Chrome and used by Google PageSpeed Insights. But there is also Lighthouse CI which is an open source CLI tool for automating running lighthouse for a CI/CD environment.
Lighthouse CI also has a server component that let’s you save reports and compare them which can be very useful.
To setup the Lighthouse CI server through docker there are 3 parts to it.
Dockerfile
Setup the docker image to run the Lighthouse CI server with the appropriate config.
package.json
The package.json file used to install the libraries and configure the server start.
lighthouserc.json
The configuration file for the server, using PostgreSQL storage and daily CRON task to collect reports from PageSpeed Insights. Check out the Lighthouse CI Server docs for more info on this. To enable the PageSpeed Insights cron task you will need to get an API Key from the official documentation.
Once the server is up and running you then need to create a project on the server, to do this run: lhci wizard
to create a new project on the server and answer the questions it asks.
Save the tokens it generates (you will need these later).
With the project setup and the PSI CRON tasks running you will then be able to see the daily reports coming in with the ability to compare reports over time.