This repository has been archived by the owner on Apr 12, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fd0de51
commit 7bd06f4
Showing
5 changed files
with
106 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/output/* | ||
!/output/.keep |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
FROM mhart/alpine-node:latest | ||
LABEL version="1.0" | ||
LABEL description="Run Google Chrome's Lighthouse Audit in the background" | ||
WORKDIR /lighthouse | ||
|
||
USER root | ||
|
||
RUN echo "http://dl-2.alpinelinux.org/alpine/edge/main" > /etc/apk/repositories && \ | ||
echo "http://dl-2.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories && \ | ||
echo "http://dl-2.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories | ||
|
||
#----------------- | ||
# Add packages | ||
#----------------- | ||
RUN apk -U --no-cache upgrade && \ | ||
apk --no-cache add xvfb\ | ||
dbus-x11\ | ||
libx11\ | ||
xorg-server\ | ||
chromium\ | ||
ttf-opensans | ||
#----------------- | ||
# Set ENV and change mode | ||
#----------------- | ||
ENV LIGHTHOUSE_CHROMIUM_PATH /usr/bin/chromium-browser | ||
|
||
ENV TZ "Europe/Berlin" | ||
ENV DEBIAN_FRONTEND noninteractive | ||
ENV DEBCONF_NONINTERACTIVE_SEEN true | ||
ENV SCREEN_WIDTH 1360 | ||
ENV SCREEN_HEIGHT 1020 | ||
ENV SCREEN_DEPTH 24 | ||
ENV DISPLAY :99 | ||
#:99.0 | ||
ENV GEOMETRY "$SCREEN_WIDTH""x""$SCREEN_HEIGHT""x""$SCREEN_DEPTH" | ||
|
||
RUN echo $TZ > /etc/timezone | ||
|
||
ADD lighthouse-chromium-xvfb.sh . | ||
RUN npm --global install yarn && yarn global add lighthouse | ||
RUN mkdir output | ||
|
||
# Minimize size | ||
|
||
RUN apk del --force curl make gcc g++ python linux-headers binutils-gold gnupg | ||
|
||
RUN rm -rf /var/lib/apt/lists/* \ | ||
/var/cache/* \ | ||
/usr/share/man \ | ||
/tmp/* \ | ||
/usr/lib/node_modules/npm/man \ | ||
/usr/lib/node_modules/npm/doc \ | ||
/usr/lib/node_modules/npm/html \ | ||
/usr/lib/node_modules/npm/scripts | ||
|
||
|
||
ENTRYPOINT ["/lighthouse/lighthouse-chromium-xvfb.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,18 @@ | ||
# lighthouse-chrome-alpine-docker | ||
Run Google's Lighthouse headless in the background | ||
# lighthouse/chromium/alpine/docker image | ||
|
||
**Run Google's Lighthouse headless in the background** | ||
|
||
This image allows you to quickly run [lighthouse](https://github.com/GoogleChrome/lighthouse) in a headless container. That's useful if you want to run it from a CI server, or in the background of your workstation. | ||
|
||
To install: | ||
|
||
```shell | ||
git clone [email protected]:MatthiasWinkelmann/lighthouse-chromium-alpine-docker.git | ||
docker build -t lighthouse-chromium-alpine-docker | ||
``` | ||
|
||
Processes within the container cannot easily access the host's file system. You can either print to STDOUT and redirect to a file, or mount a local folder in the container, as shown here: | ||
|
||
```shell | ||
run -v ./output/:/lighthouse/output/ lighthouse-chromium-alpine-docker --output-path=/lighthouse/output/results.html --save-assets --save-artifacts --output=html https://google.com | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/sh | ||
|
||
_kill_procs() { | ||
kill -TERM $chromium | ||
wait $chromium | ||
kill -TERM $xvfb | ||
} | ||
|
||
# Setup a trap to catch SIGTERM and relay it to child processes | ||
trap _kill_procs SIGTERM | ||
|
||
XVFB_WHD=${XVFB_WHD:-1280x720x16} | ||
|
||
export DISPLAY=:99 | ||
|
||
# Start Xvfb | ||
Xvfb :99 -ac -screen 0 $XVFB_WHD -nolisten tcp & | ||
|
||
xvfb=$! | ||
|
||
|
||
|
||
|
||
/usr/bin/chromium-browser --no-sandbox --user-data-dir=$TMP_PROFILE_DIR --start-maximized --no-first-run --remote-debugging-port=9222 "about:blank" & | ||
|
||
chromium=$! | ||
|
||
echo $@ | ||
lighthouse $@ |
Empty file.