Skip to content

Added example of Dockerfile #263

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM node:alpine

RUN set -eux; \
apk add --no-cache \
bash \
tini \
openssh-client \
'chromium=~79'

ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
ENV CHROME_BIN /usr/bin/chromium-browser
ENV NODE_PATH /usr/local/share/.config/yarn/global/node_modules:$NODE_PATH

COPY docker-entrypoint.sh /docker-entrypoint.sh

WORKDIR /app

RUN yarn global add [email protected].* [email protected].* && yarn cache clean

ENTRYPOINT ["/bin/sh", "/docker-entrypoint.sh"]

# COPY your files

CMD ["node"]
83 changes: 83 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/usr/bin/env bash

isCommand() {
for cmd in \
"access" \
"adduser" \
"audit" \
"bin" \
"bugs" \
"build" \
"bundle" \
"cache" \
"ci" \
"completion" \
"config" \
"dedupe" \
"deprecate" \
"dist-tag" \
"docs" \
"doctor" \
"edit" \
"explore" \
"help-search" \
"help" \
"hook" \
"init" \
"install-ci-test" \
"install-test" \
"install" \
"link" \
"logout" \
"ls" \
"npm" \
"org" \
"outdated" \
"owner" \
"pack" \
"ping" \
"prefix" \
"profile" \
"prune" \
"publish" \
"rebuild" \
"repo" \
"restart" \
"root" \
"run-script" \
"search" \
"shrinkwrap" \
"star" \
"stars" \
"start" \
"stop" \
"team" \
"test" \
"token" \
"uninstall" \
"unpublish" \
"update" \
"version" \
"view" \
"whoami"
do
if [ -z "${cmd#"$1"}" ]; then
return 0
fi
done

return 1
}

# check if the first argument passed in looks like a flag
if [ "$(printf %c "$1")" = '-' ]; then
set -- /sbin/tini -- npm "$@"
# check if the first argument passed in is composer
elif [ "$1" = 'npm' ]; then
set -- /sbin/tini -- "$@"
# check if the first argument passed in matches a known command
elif isCommand "$1"; then
set -- /sbin/tini -- npm "$@"
fi

exec "$@"
5 changes: 4 additions & 1 deletion src/Cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,15 @@ export default class Cluster<JobData = any, ReturnData = any> extends EventEmitt

private async init() {
const browserOptions = this.options.puppeteerOptions;
if (process.env.CHROME_BIN) {
browserOptions.executablePath = process.env.CHROME_BIN;
}
let puppeteer = this.options.puppeteer;

if (this.options.puppeteer == null) { // check for null or undefined
puppeteer = require('puppeteer');
} else {
debug('Using provided (custom) puppteer object.');
debug('Using provided (custom) puppeteer object.');
}

if (this.options.concurrency === Cluster.CONCURRENCY_PAGE) {
Expand Down