Skip to content

Commit

Permalink
Add Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
paoloboni committed May 9, 2021
1 parent 177ae95 commit 64f28fa
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
41 changes: 41 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
FROM alpine:edge

RUN apk update
# Installs latest Chromium (89) package.
RUN apk add --no-cache \
chromium \
nss \
freetype \
harfbuzz \
ca-certificates \
ttf-freefont \
nodejs \
npm \
yarn

# Tell Puppeteer to skip installing Chrome. We'll be using the installed package.
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true \
PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser

# Puppeteer v6.0.0 works with Chromium 89.
RUN yarn add [email protected]

# Add user so we don't need --no-sandbox.
RUN addgroup -S pptruser && adduser -S -g pptruser pptruser \
&& mkdir -p /home/pptruser/Downloads /app \
&& chown -R pptruser:pptruser /home/pptruser \
&& chown -R pptruser:pptruser /app


WORKDIR /usr/src/
COPY package*.json ./
ADD app ./app
ADD config ./config
RUN npm install
RUN chown -R pptruser:pptruser /usr/src/

EXPOSE 8080

# Run everything after as non-privileged user.
USER pptruser
CMD [ "npm", "start" ]
8 changes: 7 additions & 1 deletion app/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ app.get('/screenshots', (req, res) => {
})
.then(file => {
return captureWebsite.file(website.url, file.path, {
launchOptions: {
args: [
'--no-sandbox',
'--disable-setuid-sandbox'
]
},
overwrite: true,
headers: website.headers,
cookies: website.cookies,
Expand Down Expand Up @@ -95,4 +101,4 @@ const display_static_page = function(res, page) {
});
};

module.exports = app;
module.exports = app;

0 comments on commit 64f28fa

Please sign in to comment.