Skip to content

Commit

Permalink
update lighthouse dockerfile
Browse files Browse the repository at this point in the history
I ran into some issues attempting to run the current image of lighthouse
through the python script. In order to fix this I needed to update the
lighthouse dockerfile.

This updates the lighthouse dockerfile to use Node.js 18-slim instead
of Alpine. This will also install the latest version of lighthouse
which is currently on version 10.3.0.

Lastly this will set a couple of environment variables to configure
Chromium. The `CHROME_PATH` is needed so
that lighthouse will know where to find Chromium. This will also set
the some flags for the chromium browser so we don't need to manually
set them when running lighthouse. The flags will ensure chromium
runs in headless mode and will disable the sandbox which is need when
the container is ran as root. I also needed to
add the flag "--disable-dev-shm-usage" to prevent chromium from
crashing when running in docker.
GoogleChrome/lighthouse#6512 (comment)
  • Loading branch information
ardelato committed Jun 29, 2023
1 parent fc2bcce commit a408896
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lighthouse-docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
FROM alpine:20210212
FROM node:18-slim

WORKDIR /opt/lighthouse

RUN apk --update-cache --no-cache \
add npm chromium \
&& npm install [email protected] \
&& mkdir -p /root/.config/configstore \
&& echo '{"isErrorReportingEnabled": false}' > /root/.config/configstore/lighthouse.json
RUN apt-get update --fix-missing && apt-get -y upgrade \
&& apt-get install -y chromium \
&& npm install --global [email protected] \
&& apt-get clean

VOLUME /var/lighthouse
ENV CHROME_PATH=/usr/bin/chromium
ENV CHROMIUM_FLAGS="--headless --no-sandbox --disable-dev-shm-usage"

ENTRYPOINT [ "npx", "lighthouse" ]
ENTRYPOINT ["lighthouse"]

0 comments on commit a408896

Please sign in to comment.