|
1 |
| -FROM node:8-slim |
| 1 | +FROM node:10-slim |
2 | 2 |
|
3 |
| -RUN apt-get -qq update && apt-get -qq install -y \ |
4 |
| - libgconf-2-4 \ |
5 |
| - apt-transport-https \ |
6 |
| - ca-certificates \ |
7 |
| - curl \ |
8 |
| - gnupg \ |
9 |
| - --no-install-recommends \ |
10 |
| - && curl -sSL https://dl.google.com/linux/linux_signing_key.pub | apt-key add - \ |
11 |
| - && echo "deb [arch=amd64] https://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list \ |
12 |
| - && apt-get -qq update && apt-get -qq install -y \ |
13 |
| - google-chrome-unstable \ |
14 |
| - --no-install-recommends \ |
15 |
| - && rm -rf /var/lib/apt/lists/* |
| 3 | +# Install latest chrome dev package and fonts to support major charsets (Chinese, Japanese, Arabic, Hebrew, Thai and a few others) |
| 4 | +# Note: this installs the necessary libs to make the bundled version of Chromium that Puppeteer |
| 5 | +# installs, work. |
| 6 | +RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \ |
| 7 | + && sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \ |
| 8 | + && apt-get update \ |
| 9 | + && apt-get install -y google-chrome-unstable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf \ |
| 10 | + --no-install-recommends \ |
| 11 | + && rm -rf /var/lib/apt/lists/* |
16 | 12 |
|
17 |
| -# Add Chrome as a user |
18 |
| -RUN groupadd -r chrome && useradd -r -g chrome -G audio,video chrome \ |
19 |
| - && mkdir -p /home/chrome && chown -R chrome:chrome /home/chrome |
| 13 | +# If running Docker >= 1.13.0 use docker run's --init arg to reap zombie processes, otherwise |
| 14 | +# uncomment the following lines to have `dumb-init` as PID 1 |
| 15 | +ADD https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64 /usr/local/bin/dumb-init |
| 16 | +RUN chmod +x /usr/local/bin/dumb-init |
| 17 | +ENTRYPOINT ["dumb-init", "--"] |
20 | 18 |
|
21 |
| -WORKDIR /home/chrome |
| 19 | +# Uncomment to skip the chromium download when installing puppeteer. If you do, |
| 20 | +# you'll need to launch puppeteer with: |
| 21 | +# browser.launch({executablePath: 'google-chrome-unstable'}) |
| 22 | +# ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true |
22 | 23 |
|
23 |
| -# Run Chrome non-privileged |
24 |
| -USER chrome |
| 24 | +WORKDIR /home/pptruser |
25 | 25 |
|
26 |
| -# Expose port 9222 |
27 |
| -EXPOSE 9222 |
| 26 | +# Install puppeteer so it's available in the container. |
| 27 | +RUN npm i puppeteer \ |
| 28 | + # Add user so we don't need --no-sandbox. |
| 29 | + # same layer as npm install to keep re-chowned files from using up several hundred MBs more space |
| 30 | + && groupadd -r pptruser && useradd -r -g pptruser -G audio,video pptruser \ |
| 31 | + && mkdir -p /home/pptruser/Downloads \ |
| 32 | + && chown -R pptruser:pptruser /home/pptruser |
| 33 | +# && chown -R pptruser:pptruser /node_modules |
28 | 34 |
|
29 |
| -COPY package*.json /home/chrome/ |
| 35 | +# Run everything after as non-privileged user. |
| 36 | +USER pptruser |
| 37 | + |
| 38 | + |
| 39 | +#CMD ["google-chrome-unstable"] |
| 40 | + |
| 41 | +COPY package*.json /home/pptruser/ |
30 | 42 |
|
31 | 43 | RUN npm install
|
32 | 44 |
|
33 |
| -ENV CHROME_PATH=/usr/bin/chromium-browser |
| 45 | +#ENV CHROME_PATH=/usr/bin/chromium-browser |
34 | 46 |
|
35 |
| -COPY tasks.js /home/chrome/ |
36 |
| -COPY processes.config.js /home/chrome/ |
| 47 | +COPY tasks.js /home/pptruser/ |
| 48 | +COPY processes.config.js /home/pptruser/ |
37 | 49 |
|
38 | 50 | CMD ["node_modules/.bin/pm2-docker", "processes.config.js"]
|
0 commit comments