This project automates Lighthouse audits for both mobile and desktop platforms using Puppeteer.
981
This project automates Lighthouse audits for both mobile and desktop platforms using Puppeteer. It supports optional authentication, dynamic platform selection, and configurable report formats. The reports are stored in a reports directory, which is mounted as a Docker volume.
reports folder.Clone the repository:
git clone https://github.com/your-username/lighthouse-audit.git
cd lighthouse-audit
Build the Docker image:
docker build -t sqerison/lighthouse-audit .
To run the audit without login credentials:
docker run --rm \
-v $(pwd)/reports:/usr/src/app/reports \
-e SITE_URL="https://google.com" \
sqerison/lighthouse-audit
To run the audit with login credentials:
docker run --rm \
-v $(pwd)/reports:/usr/src/app/reports \
-e SITE_URL="https://google.com" \
-e USERNAME="your-username" \
-e PASSWORD="your-password" \
-e USERNAME_FIELD="input[name='login']" \
-e PASSWORD_FIELD="input[name='password']" \
-e SUBMIT_BUTTON="input[name='submit']" \
sqerison/lighthouse-audit
By default, the audit runs for both mobile and desktop. To specify a platform:
Desktop only:
docker run --rm \
-v $(pwd)/reports:/usr/src/app/reports \
-e SITE_URL="https://example.com" \
-e PLATFORM="desktop" \
sqerison/lighthouse-audit
Mobile only:
docker run --rm \
-v $(pwd)/reports:/usr/src/app/reports \
-e SITE_URL="https://example.com" \
-e PLATFORM="mobile" \
sqerison/lighthouse-audit
To customize Lighthouse categories, use the CATEGORIES environment variable:
docker run --rm \
-v $(pwd)/reports:/usr/src/app/reports \
-e SITE_URL="https://example.com" \
-e CATEGORIES="performance,accessibility" \
sqerison/lighthouse-audit
The default report format is html. Other types could be specified as: html, json, csv.
To specify a different format:
docker run --rm \
-v $(pwd)/reports:/usr/src/app/reports \
-e SITE_URL="https://example.com" \
-e REPORT_TYPE="json" \
sqerison/lighthouse-audit
| Variable | Default Value | Description |
|---|---|---|
SITE_URL | https://google.com | URL to audit (login or main page). |
USERNAME | None | Username for login (optional). |
PASSWORD | None | Password for login (optional). |
USERNAME_FIELD | input[name='login'] | Selector for the username field. |
PASSWORD_FIELD | input[name='password'] | Selector for the password field. |
SUBMIT_BUTTON | input[name='submit'] | Selector for the login button. |
CATEGORIES | All categories | Comma-separated list of categories to audit. |
PLATFORM | both | Platform to audit: mobile, desktop, or both. |
REPORT_TYPE | html | Report format: html, json, or csv. |
REPORT_DIR | ./reports | Directory to save the Lighthouse report. |
performance: Page load speed and efficiency.accessibility: Compliance with web accessibility best practices.best-practices: Web development best practices.seo: Search engine optimization.pwa: Progressive Web App standards.Reports are saved in the reports folder with filenames based on the platform and format:
lighthouse-report-desktop.htmllighthouse-report-mobile.htmllighthouse-report-desktop.jsonlighthouse-report-mobile.csv
(Depending on the REPORT_TYPE specified.)Ensure the reports folder is mounted as a Docker volume for easy access.
This project is licensed under the MIT License.
For inquiries or issues, please contact [email protected] or open an issue in the repository.
Content type
Image
Digest
sha256:972ee7263…
Size
287.1 MB
Last updated
over 1 year ago
docker pull sqerison/lighthouse-audit