Disable sandbox only if running inside a container
This commit is contained in:
parent
69471cb901
commit
5e379ff173
9
index.js
9
index.js
|
@ -1,4 +1,5 @@
|
||||||
const puppeteer = require('puppeteer');
|
const puppeteer = require('puppeteer');
|
||||||
|
const containerized = require('containerized');
|
||||||
|
|
||||||
const MY_PACKAGE_SELECTOR_ID =
|
const MY_PACKAGE_SELECTOR_ID =
|
||||||
'table[style="margin-top:-10px;"] tr:first-child+tr';
|
'table[style="margin-top:-10px;"] tr:first-child+tr';
|
||||||
|
@ -36,8 +37,14 @@ async function getUsage() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function chromeLaunchConfig() {
|
function chromeLaunchConfig() {
|
||||||
|
let defaultArgs = [];
|
||||||
|
if (containerized()) {
|
||||||
|
defaultArgs = ['--no-sandbox', '--disable-setuid-sandbox'];
|
||||||
|
}
|
||||||
var options = {
|
var options = {
|
||||||
args: ['--no-sandbox', '--disable-setuid-sandbox'].concat(
|
// These are set for Docker usage
|
||||||
|
// https://github.com/alekzonder/docker-puppeteer#before-usage
|
||||||
|
args: defaultArgs.concat(
|
||||||
process.env.hasOwnProperty('PROXY_SERVER')
|
process.env.hasOwnProperty('PROXY_SERVER')
|
||||||
? [`--proxy-server=${process.env['PROXY_SERVER']}`]
|
? [`--proxy-server=${process.env['PROXY_SERVER']}`]
|
||||||
: []
|
: []
|
||||||
|
|
|
@ -57,6 +57,11 @@
|
||||||
"typedarray": "^0.0.6"
|
"typedarray": "^0.0.6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"containerized": {
|
||||||
|
"version": "1.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/containerized/-/containerized-1.0.2.tgz",
|
||||||
|
"integrity": "sha1-3+0xSeq1BC7wsG6FHH2PTcZ1DYg="
|
||||||
|
},
|
||||||
"core-util-is": {
|
"core-util-is": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
|
||||||
|
|
|
@ -6,10 +6,15 @@
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
},
|
},
|
||||||
"keywords": ["actcorp", "balance", "flexibyte"],
|
"keywords": [
|
||||||
|
"actcorp",
|
||||||
|
"balance",
|
||||||
|
"flexibyte"
|
||||||
|
],
|
||||||
"author": "Nemo <npm@captnemo.in>",
|
"author": "Nemo <npm@captnemo.in>",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"containerized": "^1.0.2",
|
||||||
"prom-client": "^11.0.0",
|
"prom-client": "^11.0.0",
|
||||||
"puppeteer": "^1.4.0"
|
"puppeteer": "^1.4.0"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue