Skip to content

Commit

Permalink
Docker - run using --no-sandbox (we are already in a isolated namespace)
Browse files Browse the repository at this point in the history
  • Loading branch information
macbre committed May 3, 2019
1 parent c55e138 commit 84b9cd6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ RUN apk update && apk upgrade && \
ttf-freefont@edge

WORKDIR /opt/phantomas
ENV HOME /opt/phantomas

# Tell Puppeteer to skip installing Chrome. We'll be using the installed package.
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true

# Tell phantomas were Chromium binary is
# Tell phantomas where Chromium binary is and that we're in docker
ENV PHANTOMAS_CHROMIUM_EXECUTABLE /usr/bin/chromium-browser
ENV DOCKERIZED yes

# Add user so we don't need --no-sandbox.
RUN addgroup -S phantomas && adduser -S -g phantomas phantomas \
Expand Down
7 changes: 7 additions & 0 deletions lib/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ Browser.prototype.init = async () => {
options.executablePath = env['PHANTOMAS_CHROMIUM_EXECUTABLE'];
}

// allow Chromium to be run inside a container
// @see https://github.com/jessfraz/dockerfiles/issues/65
if (env['DOCKERIZED']) {
debug('Docker environment detected, enabling -no-sandbox switch');
options.args.push('--no-sandbox');
}

debug('Launching Puppeteer: %j', options);

try {
Expand Down

0 comments on commit 84b9cd6

Please sign in to comment.