Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lighthouse CLI Multiple URL Automation with Docker

This project allows you to run Lighthouse audits on multiple URLs automatically using a simple Bash script inside a Docker container.

Lighthouse CLI

Features

  • Automate Lighthouse audits for many URLs in one run.
  • Run inside Docker for consistent Chrome and Lighthouse environment.
  • Output reports in HTML format to a mounted directory.
  • Easily extend the script for more URLs.

Prerequisites


Setup

  1. Clone this repository

    git clone https://github.com/danisec/lighthouse-cli-with-docker.git
    
    cd lighthouse-cli-with-docker
  2. Configure URLs
    Edit run-lighthouse.sh and add your target URLs to the URLS array:

    URLS=(
     "https://google.com"
     "https://github.com"
     "https://stackoverflow.com"
     # Add more URLs here
    )
  3. Build the Docker Image

    With Docker Compose:

    docker compose build
  4. Create Reports Directory
    On your host machine:

    mkdir reports

Running the Automation

With Docker Compose

docker compose up

Output

  • After running, all HTML Lighthouse reports will be saved in the reports folder on your host machine.
  • Filenames are automatically generated based on each URL.

Customization

  • Add/Remove URLs: Edit the run-lighthouse.sh file.
  • Change Lighthouse options: Tweak the command line flags in run-lighthouse.sh (e.g., add --preset=desktop, change output format, etc), see Lighthouse CLI.

Example run-lighthouse.sh

#!/bin/bash

URLS=(
  "https://example.com"
  "https://another-url.com"
)

for url in "${URLS[@]}"; do
  basename=$(echo $url | sed 's|https\?://||;s|/|-|g')
  lighthouse "$url" \
    --chrome-flags="--headless --no-sandbox --disable-gpu --disable-dev-shm-usage" \
    --output html \
    --output-path="/home/lighthouse/reports/report-${basename}-desktop.html" \
    --preset=desktop
done

Troubleshooting

  • Out of memory or IO errors: Add --shm-size=1g (or higher) when running the container to increase shared memory.
  • Chrome not found: This image installs Chrome automatically; if issues persist, check Docker build logs for errors.
  • Permission errors: Make sure the reports directory on your host is writable.

Structure Project

  • Dockerfile: Defines the Docker image with Node.js, Lighthouse, and Chrome.
  • docker-compose.yml: Simplifies building and running the Docker container.
  • run-lighthouse.sh: The main script that runs Lighthouse on multiple URLs.
  • reports/: Directory where Lighthouse reports are saved (created on host).

References


License

The Car Wash Booking System is open-sourced software licensed under the MIT license.

About

Lighthouse CLI Multiple URLs with Docker

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages