diff options
-rw-r--r-- | Dockerfile | 47 | ||||
-rw-r--r-- | README | 18 |
2 files changed, 65 insertions, 0 deletions
diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0e46b41 --- /dev/null +++ b/Dockerfile | |||
@@ -0,0 +1,47 @@ | |||
1 | # Copy and pasted from: | ||
2 | # https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md#running-puppeteer-in-docker | ||
3 | # | ||
4 | # The only change is locking it down to a specific version of Puppeteer in the | ||
5 | # `npm install` line. | ||
6 | |||
7 | FROM node:8-slim | ||
8 | |||
9 | # See https://crbug.com/795759 | ||
10 | RUN apt-get update && apt-get install -yq libgconf-2-4 | ||
11 | |||
12 | # Install latest chrome dev package and fonts to support major charsets (Chinese, Japanese, Arabic, Hebrew, Thai and a few others) | ||
13 | # Note: this installs the necessary libs to make the bundled version of Chromium that Puppeteer | ||
14 | # installs, work. | ||
15 | RUN apt-get update && apt-get install -y wget --no-install-recommends \ | ||
16 | && wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \ | ||
17 | && sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \ | ||
18 | && apt-get update \ | ||
19 | && apt-get install -y google-chrome-unstable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst ttf-freefont \ | ||
20 | --no-install-recommends \ | ||
21 | && rm -rf /var/lib/apt/lists/* \ | ||
22 | && apt-get purge --auto-remove -y curl \ | ||
23 | && rm -rf /src/*.deb | ||
24 | |||
25 | # It's a good idea to use dumb-init to help prevent zombie chrome processes. | ||
26 | ADD https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64 /usr/local/bin/dumb-init | ||
27 | RUN chmod +x /usr/local/bin/dumb-init | ||
28 | |||
29 | # Uncomment to skip the chromium download when installing puppeteer. If you do, | ||
30 | # you'll need to launch puppeteer with: | ||
31 | # browser.launch({executablePath: 'google-chrome-unstable'}) | ||
32 | # ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true | ||
33 | |||
34 | # Install puppeteer so it's available in the container. | ||
35 | RUN npm i puppeteer@1.1.1 | ||
36 | |||
37 | # Add user so we don't need --no-sandbox. | ||
38 | RUN groupadd -r pptruser && useradd -r -g pptruser -G audio,video pptruser \ | ||
39 | && mkdir -p /home/pptruser/Downloads \ | ||
40 | && chown -R pptruser:pptruser /home/pptruser \ | ||
41 | && chown -R pptruser:pptruser /node_modules | ||
42 | |||
43 | # Run everything after as non-privileged user. | ||
44 | USER pptruser | ||
45 | |||
46 | ENTRYPOINT ["dumb-init", "--"] | ||
47 | CMD ["google-chrome-unstable"] \ No newline at end of file | ||
@@ -0,0 +1,18 @@ | |||
1 | # Docker Puppeteer | ||
2 | |||
3 | A Puppeteer Docker image based on the code here (Apache 2.0 license): | ||
4 | https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md#running-puppeteer-in-docker | ||
5 | |||
6 | An example for how to use: | ||
7 | |||
8 | ```Dockerfile | ||
9 | FROM buildkite/puppeteer | ||
10 | |||
11 | RUN npm install mocha | ||
12 | ENV PATH="${PATH}:/node_modules/.bin" | ||
13 | |||
14 | # The `tests` dir is expected to be mounted into here | ||
15 | WORK_DIR /home/pptr | ||
16 | |||
17 | CMD ["mocha", "--recursive", "tests"] | ||
18 | ``` \ No newline at end of file | ||