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

Commit

Permalink
fixed spurious glx errors
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthiasWinkelmann committed Mar 18, 2017
1 parent 3a4c1f1 commit f712f8e
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 47 deletions.
69 changes: 32 additions & 37 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,10 @@ WORKDIR /

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\
openrc\
dbus-x11\
libx11\
xorg-server\
ttf-opensans\
wait4ports\
chromium
RUN echo "http://dl-2.alpinelinux.org/alpine/edge/main" > /etc/apk/repositories
RUN echo "http://dl-2.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories
RUN echo "http://dl-2.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories
RUN echo "http://dl-2.alpinelinux.org/alpine/v3.2/main" >> /etc/apk/repositories

#-----------------
# Set ENV and change mode
Expand All @@ -43,31 +31,43 @@ ENV SCREEN_HEIGHT 1334
ENV SCREEN_DEPTH 24
ENV DISPLAY :99.0
ENV PATH /lighthouse/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
#:99.0

ENV GEOMETRY "$SCREEN_WIDTH""x""$SCREEN_HEIGHT""x""$SCREEN_DEPTH"

RUN echo $TZ > /etc/timezone

RUN rc-update add dbus default


#RUN npm --global install yarn && yarn global add lighthouse

# DEV

RUN apk add git libressl
#-----------------
# Add packages
#-----------------

RUN apk -U --no-cache update
RUN apk -U --no-cache add \
zlib-dev \
chromium \
xvfb \
wait4ports \
xorg-server \
dbus-x11 \
dbus \
ttf-freefont \
mesa-dri-swrast \
git

# DEV Version of lighthouse

RUN apk -U --no-cache add git
RUN git clone https://github.com/GoogleChrome/lighthouse.git

WORKDIR /lighthouse
RUN npm -g install yarn
RUN yarn install
RUN cd ./lighthouse-core && yarn install
RUN cd ./lighthouse-cli && yarn install && tsc
RUN npm run install-all && npm run build-all && npm link

RUN npm install && npm run install-all && npm run build-all && npm link


RUN apk del --force git libressl
# Minimize size

RUN apk del --force curl make gcc g++ python linux-headers binutils-gold gnupg
RUN apk del --force curl make gcc g++ python linux-headers binutils-gold gnupg git

RUN rm -rf /var/lib/apt/lists/* \
/var/cache/apk/* \
Expand All @@ -79,15 +79,10 @@ RUN rm -rf /var/lib/apt/lists/* \
/usr/lib/node_modules/npm/scripts


ADD lighthouse-chromium-xvfb.sh .

# Alpine's grep is a BusyBox binary which doesn't provide
# the -R (recursive, following symlinks) switch.
#ADD grep ./grep
# RUN alias grep=/lighthouse/grep
ADD lighthouse-chromium-xvfb.sh /lighthouse/lighthouse-chromium-xvfb.sh

VOLUME /lighthouse/output

ENTRYPOINT ["/lighthouse/lighthouse-chromium-xvfb.sh"]

CMD ["--skip-autolaunch","--disable-cpu-throttling=true","--output-path=/tmp/test-report.html", "--output=pretty", "https://matthi.coffee/2017/lighthouse-chromium-headless-docker"]
CMD ["test"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ docker run -v ./output/:/lighthouse/output/ lighthouse --output-path=/lighthouse
## Testing

```shell
docker run lighthouse
docker run lighthouse test
```

## Links
Expand Down
22 changes: 13 additions & 9 deletions lighthouse-chromium-xvfb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,19 @@ _kill_procs() {
}

testing=0
echo $@ | grep -q -F 'matthi.coffee' && testing=1;
if [ "$testing" -eq "1" ]; then
printf "\n\nNo options given, running test...\n\nRun with an URL, or '--help' to see options\n\n";
parameters=$@

if [ $parameters == 'test' ]; then
testing=1;
parameters='--skip-autolaunch --disable-cpu-throttling --output-path=/tmp/test-report.html --output=html https://google.com"'
printf "\n\nRunning test...\n\nRun with an URL, or '--help' to see options\n\n";
fi

# We need to test if /var/run/dbus exists, since script will fail if it does not

[ ! -e /var/run/dbus ] && mkdir /var/run/dbus

start-stop-daemon --start --pidfile /var/run/dbus.pid --exec /usr/bin/dbus-daemon -- --system
/usr/bin/dbus-daemon --system

# Setup a trap to catch SIGTERM and relay it to child processes
trap _kill_procs SIGTERM
Expand All @@ -25,9 +28,7 @@ TMP_PROFILE_DIR=`mktemp -d -t chromium.XXXXXX`
export CHROME_DEBUGGING_PORT=9222

# Start Xvfb
Xvfb ${DISPLAY} -ac -screen 0 ${GEOMETRY} -nolisten tcp &

xvfb=$!
Xvfb ${DISPLAY} -ac +iglx -screen 0 ${GEOMETRY} -nolisten tcp & xvfb=$!

printf "Starting xvfb window server"

Expand All @@ -37,10 +38,11 @@ printf "xvfb started"

printf "Starting chromium, with debugger on port $CHROME_DEBUGGING_POST"

# --disable-webgl \

$LIGHTHOUSE_CHROMIUM_PATH \
--no-sandbox \
--user-data-dir=${TMP_PROFILE_DIR} \
--disable-webgl \
--start-maximized \
--remote-debugging-port=${CHROME_DEBUGGING_PORT} \
--no-first-run "about:blank" &
Expand All @@ -52,14 +54,16 @@ wait4ports tcp://127.0.0.1:$CHROME_DEBUGGING_PORT
printf "chromium started"

printf "launching lighthouse run"
lighthouse $@

if [ "$testing" -eq "1" ]; then
lighthouse --skip-autolaunch --disable-cpu-throttling --output-path=/tmp/test-report.html --output=html https://google.com
if grep -q -F "Best Practice" /tmp/test-report*; then
printf "Test succeeded!";
return 0;
fi

printf "Test failed!";
return 1;
else
lighthouse $@
fi

0 comments on commit f712f8e

Please sign in to comment.