-
Notifications
You must be signed in to change notification settings - Fork 394
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
Can we set executablePath of puppeteer? #93
Labels
Comments
react-snap now can run in mhart/alpine-node:9 ! Example Dockerfile is as follow: # Dockerfile.alpine
FROM mhart/alpine-node:9
RUN apk update && \
apk upgrade && \
apk add --update ca-certificates && \
apk add bash git openssh chromium --update-cache --repository http://nl.alpinelinux.org/alpine/edge/community \
rm -rf /var/cache/apk/*
# If you have native dependencies, you'll need extra tools
# RUN apk add --no-cache make gcc g++ python
# Setup yarn
RUN yarn config set registry https://registry.npm.taobao.org
# Create app directory and bundle app source
RUN mkdir -p /usr/src/app
# use changes to package.json to force Docker not to use the cache
# when we change our application's nodejs dependencies:
COPY package.json /tmp/package.json
COPY yarn.lock /tmp/yarn.lock
RUN cd /tmp && yarn
RUN mkdir -p /usr/src/app && cp -a /tmp/node_modules /usr/src/app/
# simple http server
RUN yarn global add serve
# From here we load our application's code in, therefore the previous docker
# "layer" thats been cached will be used if possible
WORKDIR /usr/src/app
COPY . /usr/src/app
RUN yarn build
# Expose port
EXPOSE 5000
CMD [ "serve", "-s", "./build" ] |
Weird, it stop at: $ react-snap
✏ / log: Content is cached for offline use. I will try figuring out what happened tomorrow. |
Latest working example: # Dockerfile.alpine
FROM mhart/alpine-node:latest
# Setup yarn
# RUN yarn config set registry https://registry.npm.taobao.org
# Create app directory
RUN mkdir -p /usr/src/app
# Installs the latest Chromium (64) package.
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories
RUN apk update && apk upgrade && \
echo @edge http://nl.alpinelinux.org/alpine/edge/community >> /etc/apk/repositories && \
echo @edge http://nl.alpinelinux.org/alpine/edge/main >> /etc/apk/repositories
RUN apk add --no-cache nss@edge
RUN apk add --no-cache chromium@edge
# Tell Puppeteer to skip installing Chrome. We'll be using the installed package.
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
# Puppeteer v0.13.0 works with Chromium 64.
RUN yarn add puppeteer@0.13.0
# Add user so we don't need --no-sandbox. (Currently broken, commented.)
# RUN addgroup -S pptruser && adduser -S -g pptruser pptruser \
# && mkdir -p /home/pptruser/Downloads \
# && chown -R pptruser:pptruser /home/pptruser \
# && chown -R pptruser:pptruser /usr/src/app
# # Run everything after as non-privileged user.
# USER pptruser
# bundle app source
# use changes to package.json to force Docker not to use the cache
# when we change our application's nodejs dependencies:
COPY package.json /tmp/package.json
COPY yarn.lock /tmp/yarn.lock
# RUN sed -i '' 's/registry.npm.taobao.org/registry.npmjs.org/g' yarn.lock
RUN cd /tmp && yarn
RUN cp -a /tmp/node_modules /usr/src/app/
# simple HTTP server
RUN yarn global add http-server
# From here we load our application's code in, therefore the previous docker
# "layer" that's been cached will be used if possible
WORKDIR /usr/src/app
COPY . /usr/src/app
RUN yarn build
# Expose port
EXPOSE 5000
CMD [ "http-server", "./build", "-g", "-p", "5000", "-P" ] with config: {
"reactSnap": {
"puppeteerArgs": [
"--disable-setuid-sandbox", "--no-sandbox"
],
"concurrency": 1,
"inlineCss": false,
"puppeteerExecutablePath": "/usr/bin/chromium-browser"
}
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As puppeteer/puppeteer#379 (comment) , to run react-snap in a docker, we should be able to set executablePath to '/usr/bin/chromium-browser' or somewhere else.
The text was updated successfully, but these errors were encountered: