Skip to content
This repository has been archived by the owner on Apr 12, 2018. It is now read-only.

Commit

Permalink
1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthiasWinkelmann committed Mar 7, 2017
1 parent fd0de51 commit 7bd06f4
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/output/*
!/output/.keep
57 changes: 57 additions & 0 deletions Dockerfile
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"]
20 changes: 18 additions & 2 deletions README.md
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 git@github.com: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
```
29 changes: 29 additions & 0 deletions lighthouse-chromium-xvfb.sh
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 added output/.keep
Empty file.

0 comments on commit 7bd06f4

Please sign in to comment.