Skip to content

Commit 2b63b1b

Browse files
committed
Google Lighthouse Docker image
0 parents  commit 2b63b1b

File tree

3 files changed

+75
-0
lines changed

3 files changed

+75
-0
lines changed

Dockerfile

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
FROM bitnami/minideb
2+
3+
ENV CHROME_PORT=9222
4+
5+
# Install deps + add Chrome Stable + purge all the things
6+
RUN apt-get update && apt-get install -y apt-transport-https ca-certificates curl gnupg --no-install-recommends && \
7+
curl -sSL https://deb.nodesource.com/setup_9.x | bash - && \
8+
curl -sSL https://dl.google.com/linux/linux_signing_key.pub | apt-key add - && \
9+
echo "deb [arch=amd64] https://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list && \
10+
apt-get update && apt-get install -y google-chrome-stable nodejs --no-install-recommends && \
11+
npm --global install yarn && \
12+
apt-get purge --auto-remove -y curl gnupg && \
13+
rm -rf /var/lib/apt/lists/* && \
14+
yarn global add lighthouse && \
15+
groupadd -r chrome && useradd -r -g chrome -G audio,video chrome && \
16+
mkdir -p /home/chrome/reports && chown -R chrome:chrome /home/chrome
17+
18+
# some place we can mount and view lighthouse reports
19+
VOLUME /home/chrome/reports
20+
WORKDIR /home/chrome/reports
21+
22+
23+
COPY entrypoint.sh /usr/bin/entrypoint
24+
25+
# Run Chrome non-privileged
26+
USER chrome
27+
28+
VOLUME /home/chrome/reports
29+
30+
# Drop to cli
31+
ENTRYPOINT ["entrypoint"]

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
Google Lighthouse - Docker Image
2+
================================
3+
4+
[![Docker Pulls](https://img.shields.io/docker/pulls/femtopixel/google-lighthouse.svg)](https://hub.docker.com/r/femtopixel/google-lighthouse/)
5+
6+
[Lighthouse](https://developers.google.com/web/tools/lighthouse/) analyzes web apps and web pages, collecting modern performance metrics and insights on developer best practices.
7+
8+
This image is greatly inspired from [Justin RIBEIRO's work](https://github.com/justinribeiro/dockerfiles/tree/master/lighthouse)
9+
10+
Usage
11+
-----
12+
13+
```
14+
docker run --rm --name lighthouse -it -v /path/to/your/report:/home/chrome/reports --cap-add=SYS_ADMIN femtopixel/google-lighthouse <your_site_url> <optional_args>
15+
```
16+
17+
With `<you_site_url>` url to your site (e.g. http://www.google.com). You can pass args **AFTER** the `url` if you want to.
18+
19+
For example, you can export as json with this command:
20+
21+
```
22+
docker run --rm --name lighthouse -it -v /path/to/your/report:/home/chrome/reports --cap-add=SYS_ADMIN femtopixel/google-lighthouse http://www.google.com --output json
23+
```
24+
25+
Further reading on [Google Lighthouse](https://github.com/GoogleChrome/lighthouse#using-programmatically)
26+
27+
Usage : Improved
28+
----------------
29+
30+
Using the ever-awesome [Jessie Frazelle](https://twitter.com/jessfraz) SECCOMP profile for Chrome, we don't have to use the hammer that is SYS_ADMIN:
31+
32+
```
33+
wget https://raw.githubusercontent.com/jfrazelle/dotfiles/master/etc/docker/seccomp/chrome.json -O ~/chrome.json
34+
docker run --rm --name lighthouse -it -v /path/to/your/report:/home/chrome/reports --security-opt seccomp=$HOME/chrome.json femtopixel/google-lighthouse <your_site_url>
35+
```

entrypoint.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/sh
2+
set -e
3+
4+
# first arg is `-f` or `--some-option`
5+
if [ "${1#http}" != "$1" ]; then
6+
set -- lighthouse --chrome-flags="--headless --disable-gpu" "$@"
7+
fi
8+
9+
exec "$@"

0 commit comments

Comments
 (0)