Skip to content
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

Fix backend dockerfile #55

Open
zetos opened this issue May 8, 2020 · 0 comments
Open

Fix backend dockerfile #55

zetos opened this issue May 8, 2020 · 0 comments

Comments

@zetos
Copy link

zetos commented May 8, 2020

The build script is no longer working.

Some needed changes:

  • Update node version on the Dockerfile.
  • The command RUN npm install puppeteer will install the puppeteer 3.x.x with can have breaking changes.

This is a suggestion for a Dockerfile that worked for me. I changes the node image to use Alpine, and added the "puppeteer": "^2.0.0" dependency on the package.json.

I also changed the following lines on the server.js from:

    code = code.replace(/\.launch\([\w\W]*?\)/g,
        ".launch({args: ['--no-sandbox', '--disable-dev-shm-usage']})");

to:

    code = code.replace(/\.launch\([\w\W]*?\)/g,
        ".launch({executablePath: '/usr/bin/chromium-browser', args: ['--disable-dev-shm-usage']})");

Dockerfile:

FROM node:alpine

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

# Installs latest Chromium (79) package.
RUN apk add --no-cache \
      chromium \
      nss \
      freetype \
      freetype-dev \
      harfbuzz \
      ca-certificates \
      ttf-freefont

ADD https://github.com/Yelp/dumb-init/releases/download/v1.2.1/dumb-init_1.2.1_amd64 /usr/local/bin/dumb-init
RUN chmod +x /usr/local/bin/dumb-init

WORKDIR /usr/src/app

COPY . .
COPY package*.json ./

# Install deps for server.
RUN npm install --only=production

# building the image.
ARG CACHEBUST=1

# Add pptr user.
RUN addgroup -S pptruser && adduser -S -G pptruser pptruser \
    && mkdir -p /home/pptruser/Downloads \
    && chown -R pptruser:pptruser /home/pptruser \
    && chown -R pptruser:pptruser ../app

# Run user as non privileged.
USER pptruser

EXPOSE 8080

ENTRYPOINT ["dumb-init", "--"]
CMD ["node", "server.js"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant