-
Notifications
You must be signed in to change notification settings - Fork 392
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
Container build failing in Docker when react-snap is enabled #132
Comments
I have no idea. You didn't show actual error message. You didn't show config of react-snap. Did you try advices from https://github.com/stereobooster/react-snap#containers-and-other-restricted-environments? |
ReactSnap settings are as below but the container's still not building:
I've requested error logs from server engineers, will paste shortly. |
Full build log:
|
there is no such executable? Remove |
Solved. For anyone having issues with Chromium running in Alpine, consider the following in your Dockerfile:
|
Nice. I will add link to this issue in Readme |
According to latest https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md#running-on-alpine, latest Dockerfile can be: # 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.
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" ] But pptruser seems useless since it still errors out: |
Was struggling with making
with disabled sandbox) and ended up building the app completely in Docker instead while using "buildkite/puppeteer" (https://hub.docker.com/r/buildkite/puppeteer) as a starting point (incorporating some of the ideas here and there): # https://hub.docker.com/r/buildkite/puppeteer/
FROM buildkite/puppeteer as builder
COPY . /app
RUN cd /app && yarn install && yarn run build-snap
# https://hub.docker.com/_/nginx
FROM nginx:alpine
COPY --from=builder /app/build /usr/share/nginx/html
COPY nginx/nginx.conf /etc/nginx/nginx.conf While still disabling Chromium sandbox through "reactSnap" config in "package.json":
Scripts section:
Had also to update from module.exports = {
globDirectory: '.',
globPatterns: [
"build/static/css/*.css",
"build/static/js/*.js",
"build/200.html",
"build/index.html"
],
swDest: 'build/service-worker.js',
navigateFallback: "/200.html",
// Ignores URLs starting from /__ (useful for Firebase):
// https://github.com/facebookincubator/create-react-app/issues/2237#issuecomment-302693219
navigateFallbackWhitelist: [/^(?!\/__).*/],
// By default, a cache-busting query parameter is appended to requests
// used to populate the caches, to ensure the responses are fresh.
// If a URL is already hashed by Webpack, then there is no concern
// about it being stale, and the cache-busting can be skipped.
dontCacheBustURLsMatching: /\.\w{8}\./,
runtimeCaching: [
{
urlPattern: /api/,
handler: "StaleWhileRevalidate"
}
]
}; Seems to work now :) |
@skivol Thanks for your info. The |
Can anyone help me out a little bit here? Build Error
Script Section
Docker Config
|
https://hub.docker.com/r/buildkite/puppeteer ❤️
|
My app works fine locally but I can't for the life of me get it to build in Docker. It works fine when I disable react-snap, but any time it's enabled, the build fails while building the image in Jenkins. My Dockerfile is pasted below, it's based mostly on what I've got from our server engineers:
I have the following in my package.json as well:
Any ideas where I'm going wrong? Cheers.
The text was updated successfully, but these errors were encountered: