1# Docker container with Google Chrome and puppeteer. 2# 3# Tests will be run as non-root (user skia, in fact), so /OUT should have permissions 4# 777 so as to be able to create output there. 5 6FROM node:8.11 7 8RUN apt-get update && apt-get upgrade -y 9 10RUN wget https://github.com/Yelp/dumb-init/releases/download/v1.2.2/dumb-init_1.2.2_amd64.deb 11RUN dpkg -i dumb-init_*.deb 12 13# https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md#running-puppeteer-in-docker 14# recommends using dumb-init to "prevent zombie chrome processes" 15ENTRYPOINT ["/usr/bin/dumb-init", "--"] 16 17RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - 18RUN sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' 19RUN apt-get update && apt-get install -y google-chrome-stable 20 21ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true 22 23RUN npm install --global \ 24 command-line-args@5.0.2 \ 25 command-line-usage@5.0.3 \ 26 express@4.16.3 \ 27 node-fetch@2.2.0 \ 28 puppeteer@1.6.2 29 30# Allows require('puppeteer') to work from anywhere. 31# https://stackoverflow.com/a/15646750 32ENV NODE_PATH=/usr/local/lib/node_modules 33 34#Add user so we don't have to run as root (prevents us from over-writing files in /SRC) 35RUN groupadd -g 2000 skia \ 36 && useradd -u 2000 -g 2000 skia \ 37 && mkdir -p /home/skia \ 38 && chown -R skia:skia /home/skia 39 40# These directories can be used for mounting a source checkout and having a place to put outputs. 41RUN mkdir -m 0777 /SRC /OUT 42 43# Run everything after as non-privileged user. 44USER skia 45 46WORKDIR /home/skia