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