Skip to content

A Docker image to industrialize web quality measurement

Notifications You must be signed in to change notification settings

faberNovel/heart-docker

Repository files navigation

Violet square with rounded corners,
            featuring a heart in the form of a cloud of dots.
            Some of the dots are interconnected

A command-line tool to industrialize web quality measurement.

Description

Heart is a tool that centralize the use of famous web quality measurement services (Google Lighthouse, GreenIT Analysis or Mozilla Observatory) in a unique CLI.

With his modular approach, it makes easy to process the analysis results into a database to track metrics over time, or send them into a communication tool like Slack.

Moreover, the command-line interface allows a smooth integration into a CI/CD chain.

For more details, see Heart's website and Heart's repository.

Usage

I want to:

  • analyze https://heart.fabernovel.com/ using the Google Lighthouse service.
  • get the main metrics and advices on a heart Slack channel when the analysis is over.

Run the container as an executable

In the following commands:

  • replace xoxb-rest-of-token by your Slack API token.

With the configuration as an inlined JSON

docker run --rm\
    --env HEART_SLACK_API_TOKEN=xoxb-rest-of-token\
    fabernovel/heart:latest\
    lighthouse --config '{"url":"https://heart.fabernovel.com"}' --only-listeners=slack

💡 Heart as been designed to trigger all installed listener modules. The philosophy behind this is that you only install the modules you need. But in order to provide all module feature through a single Docker image, all modules had to be installed. So if you don't want to trigger all listener modules, don't forget to use the --only-listeners or --except-listeners option.

With the configuration as a file on the host machine

Instead of an inlined JSON given to the --config option, you could prefer to specify the path to a file located on your host machine.

To achieve that, you will have to map the host filesystem with the one from the container with the --volume option of the command:

docker run --rm\
    --volume "$(pwd)/ci/config:/usr/heart/config"\
    --env HEART_SLACK_API_TOKEN=xoxb-rest-of-token\
    fabernovel/heart:latest\
    lighthouse --config config/lighthouse.json --only-listeners=slack

💡 Explainations:

  • $(pwd)/ci/config is the path on your host machine where the lighthouse.json file is located
  • /usr/heart is the path inside the container where Heart is located

Integration in a CI/CD chain

Take a look at the GitHub Action as an exemple of how to integrate this Docker image.