Skip to content

Instantly share code, notes, and snippets.

@slhck
Created February 15, 2023 19:44
Show Gist options
  • Save slhck/142a4efaffbaaa9735d3f813262f39b9 to your computer and use it in GitHub Desktop.
Save slhck/142a4efaffbaaa9735d3f813262f39b9 to your computer and use it in GitHub Desktop.
Dockerfile for Google Lighthouse
# syntax=docker/dockerfile:1
FROM debian:bullseye
ENV DEBIAN_FRONTEND noninteractive
# ==============================================================================
# Main dependencies
RUN apt-get update -qq \
&& apt-get install -y \
bzip2 \
curl \
wget \
x11-utils \
x11-xserver-utils \
xvfb \
xz-utils \
&& apt-get clean -y && apt-get autoremove -y \
&& rm -rf /var/lib/apt/lists/*
# install cron, chromium and chromedriver without recommended extras
RUN apt-get update -qq \
&& apt-get install -y --no-install-recommends \
cron \
chromium \
chromium-driver \
&& apt-get clean -y && apt-get autoremove -y \
&& rm -rf /var/lib/apt/lists/*
# install node.js
RUN curl -sL https://deb.nodesource.com/setup_18.x | bash - \
&& apt-get install -qq -y nodejs \
&& apt-get clean -y && apt-get autoremove -y \
&& rm -rf /var/lib/apt/lists/* \
&& npm cache clean --force
# lighthouse
RUN npm install -g lighthouse
# add user
RUN addgroup --system --gid 1001 tester
RUN adduser --system --uid 1001 tester --shell /bin/bash
USER tester
WORKDIR /home/tester/
lighthouse \
--only-categories=performance \
--output=json \
--output-path="/home/tester/report-$(date +%Y-%m-%dT%H:%M:%S).json" \
--chrome-flags="--headless --disable-gpu --no-sandbox --disable-setuid-sandbox --disable-dev-shm-usage --disable-notifications --autoplay-policy=no-user-gesture-required --enable-benchmarking --enable-net-benchmarking --disable-features=Translate --disable-background-networking --disable-client-side-phishing-detection --disable-sync --no-default-browser-check --no-first-run --disable-ipc-flooding-protection --password-store=basic --use-mock-keychain" \
--no-enable-error-reporting \
https://google.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment