Skip to content

Updates to node & linux+npm dependencies #17

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 17 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
FROM node:8.2.0
FROM node:current-bullseye

ENV APP_HOME /app_home
RUN mkdir $APP_HOME
WORKDIR $APP_HOME
ADD . $APP_HOME

RUN npm install -g yarn

RUN apt-get update && apt-get install -yq libgconf-2-4
RUN apt-get update && apt-get install -y chromium libnss3 gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation lsb-release xdg-utils wget

# Install latest chrome dev package.
# Note: this installs the necessary libs to make the bundled version of Chromium that Puppeteer
# installs, work.
RUN apt-get update && apt-get install -y wget --no-install-recommends \
&& wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
&& apt-get update \
&& apt-get install -y google-chrome-stable \
--no-install-recommends \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get purge --auto-remove -y curl \
&& rm -rf /src/*.deb
#RUN apt-get update && apt-get install -y wget --no-install-recommends \
# && wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
# && sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
# && apt-get update \
# && apt-get install -y google-chrome-stable \
# --no-install-recommends \
# && rm -rf /var/lib/apt/lists/* \
# && apt-get purge --auto-remove -y curl \
# && rm -rf /src/*.deb

#RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb && apt install ./google-chrome-stable_current_amd64.deb


ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
#ENV PUPPETEER_EXECUTABLE_PATH which chromium`

# Install puppeteer so it's available in the container.
RUN yarn add puppeteer
Expand Down
11 changes: 7 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
version: '2'
services:
redis:
image: redis:2.8
image: redis:7-bullseye
ports:
- '6739:6379'
command: redis-server --save "" --appendonly no
critical-css:
image: critical-css-server:latest
build: .
command: npm start
ports:
- '5000:5000'
- '5001:5001'
depends_on:
- redis
volumes:
- ./:/app_home:delegated
- ./:/app_home:delegated
environment:
- NODE_TLS_REJECT_UNAUTHORIZED=0
5 changes: 4 additions & 1 deletion docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/bin/bash
set -e
export PORT=5000
export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
export PUPPETEER_EXECUTABLE_PATH=`which chromium`
export PORT=5001
export REDIS_URL=redis://redis
export
yarn install
exec "$@"
21 changes: 11 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,24 @@
"license": "MIT",
"dependencies": {
"bluebird": "3.4.7",
"body-parser": "1.16.0",
"bull": "3.3.7",
"body-parser": "1.19.0",
"bull": "3.29.2",
"cluster": "0.7.7",
"express": "4.14.1",
"extend": "3.0.0",
"penthouse": "1.3.0",
"redis": "2.6.5",
"express": "4.17.1",
"extend": "3.0.2",
"mocha": "9.1.1",
"penthouse": "2.3.2",
"redis": "3.1.2",
"redis-url": "1.2.1",
"request": "2.79.0",
"request": "2.88.2",
"yarn": "1.0.2"
},
"devDependencies": {
"expect.js": "0.3.1",
"mocha": "3.2.0",
"prettier": "1.6.1",
"redis-mock": "0.16.0",
"redis-mock": "0.56.3",
"simple-mock": "0.7.3",
"supertest": "3.0.0"
}
},
"resolutions": {}
}
20 changes: 18 additions & 2 deletions src/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var penthouse = require('penthouse');
var fs = require('fs');
var tmpDir = require('os').tmpdir();
var extend = require('extend');

var puppeteer = require('puppeteer')
var tmpPath = path.join(tmpDir, 'crit.css');
var forced = [];

Expand All @@ -22,17 +22,33 @@ var generate = bluebird.promisify(function(
try {
options = extend({}, defaultOptions, options);

request({uri: cssUrl, timeout: 10000})
request({uri: cssUrl, timeout: 10000, rejectUnauthorized:false})
.on('error', callback)
.pipe(fs.createWriteStream(tmpPath))
.on('error', callback)
.on('close', function() {

const browserPromise = puppeteer.launch({
ignoreHTTPSErrors: true,
args: ['--disable-setuid-sandbox', '--no-sandbox'],
// not required to specify here, but saves Penthouse some work if you will
// re-use the same viewport for most penthouse calls.
defaultViewport: {
width: 1300,
height: 900
}
})

penthouse(
extend(options, {
url: sourceUrl,
css: tmpPath,
strict: true,
phantomJsOptions: phantomJsOptions,
puppeteer: {
getBrowser: () => browserPromise,
pageGotoOptions: {waitUntil: 'networkidle0'}
}
}),
)
.then(function(criticalCss) {
Expand Down
2 changes: 1 addition & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var workerCount = process.env.CONCURRENCY || 1;
var app = require('./app.js')();
var queue = require('./generatorQueue.js');
var workers = require('./workers.js')(queue);
var port = process.env.PORT || 5000;
var port = process.env.PORT || 5001;

if (cluster.isMaster) {
setInterval(function() {
Expand Down
Loading