Skip to content

Commit

Permalink
prerender
Browse files Browse the repository at this point in the history
  • Loading branch information
alberto98fx authored Jun 23, 2023
1 parent 50cd850 commit bbe0798
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 20 deletions.
37 changes: 20 additions & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
FROM node:latest
LABEL maintainer="Freeletics GmbH <operations@freeletics.com>"

RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
&& apt-get update -y \
&& apt-get install -y libdrm2 libgbm1 libu2f-udev \
&& apt-get install google-chrome-stable -y \
&& apt-get clean \
&& rm -rf /tmp/* /var/lib/apt/lists/*

WORKDIR /home/chrome
COPY . /home/chrome
RUN npm install
RUN npm install prerender-memory-cache --save
FROM node:18-alpine

RUN apk update
RUN apk add --update-cache curl wget nano chromium

ENV CACHE_MAXSIZE=1000
ENV CACHE_TTL=6000

ENV CHROME_BIN=/usr/bin/chromium-browser
ENV CHROME_PATH=/usr/lib/chromium/

EXPOSE 3000

CMD [ "node", "server.js" ]
USER node
WORKDIR "/home/node"

COPY ./package.json .
COPY ./server.js .

RUN npm install --no-package-lock

EXPOSE 3000

CMD ["node", "server.js"]
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"compression": "~1.7.3",
"express": "~4.16.3",
"he": "~1.1.1",
"valid-url": "~1.0.9"
"valid-url": "~1.0.9",
"prerender-memory-cache": "1.0.2"
},
"devDependencies": {
"mocha": "^5.2.0",
Expand Down
5 changes: 3 additions & 2 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
var prerender = require('./lib');

var server = prerender({
chromeLocation: '/usr/bin/chromium-browser',
logRequests: true,
chromeFlags: ['--disable-web-security', '--no-sandbox', '--headless', '--disable-gpu', '--remote-debugging-port=9222', '--hide-scrollbars']
chromeFlags: ['--disable-web-security', '--no-sandbox', '--headless', '--disable-gpu', '--remote-debugging-port=9222', '--hide-scrollbars', '--disable-dev-shm-usage']
});

server.use(prerender.sendPrerenderHeader());
// server.use(prerender.blockResources());
server.use(prerender.blockResources());
server.use(prerender.removeScriptTags());
server.use(prerender.httpHeaders());
server.use(require('prerender-memory-cache'))
Expand Down

0 comments on commit bbe0798

Please sign in to comment.