Closed andyearnshaw closed 1 year ago
this is not even needed my newer solution shows that you can directly use the docker binary as replacement for chrome you only need to ignore all default arguments and supply your own.
but the shell version is working always even if the default parameters would change you need to choose the design for your solution but i guess at the end it is the most best to ignore all puppeteer defaults and supply then own arguments
i will raise a PR in puppeteer to allow connecting a existing child.
node_modules/puppeteer/lib/cjs/puppeteer/node/Launcher.js#L141
holds
defaultArgs(options = {}) {
const chromeArguments = [
'--allow-pre-commit-input',
'--disable-background-networking',
'--enable-features=NetworkService,NetworkServiceInProcess',
'--disable-background-timer-throttling',
'--disable-backgrounding-occluded-windows',
'--disable-breakpad',
'--disable-client-side-phishing-detection',
'--disable-component-extensions-with-background-pages',
'--disable-default-apps',
'--disable-dev-shm-usage',
'--disable-extensions',
// TODO: remove AvoidUnnecessaryBeforeUnloadCheckSync below
// once crbug.com/1324138 is fixed and released.
'--disable-features=Translate,BackForwardCache,AvoidUnnecessaryBeforeUnloadCheckSync',
'--disable-hang-monitor',
'--disable-ipc-flooding-protection',
'--disable-popup-blocking',
'--disable-prompt-on-repost',
'--disable-renderer-backgrounding',
'--disable-sync',
'--force-color-profile=srgb',
'--metrics-recording-only',
'--no-first-run',
'--enable-automation',
'--password-store=basic',
'--use-mock-keychain',
// TODO(sadym): remove '--enable-blink-features=IdleDetection'
// once IdleDetection is turned on by default.
'--enable-blink-features=IdleDetection',
'--export-tagged-pdf',
];
import
import Puppeteer from 'puppeteer';
in case of firefox inside docker set product before running the next part:
Puppeteer._productName = 'firefox'
finaly launch
Puppeteer.launch({
ignoreDefaultArgs: true, // use only our supplyed args: []
executablePath: '/usr/bin/docker', // we want to run docker right?
args: [
// docker arguments
'run',
'-p=9333:9333',
'-p=3000:3000',
'-it',
`${dockerImage}`,
`/usr/bin/google-chrome`,
// end docker arguments
...Puppeteer._launcher.defaultArgs({
devtools: false, // devtools auto open needs headless false
headless: true, // needs to be false if devtools auto open
userDataDir // needs to get set here no where else is optional
}),
// Here comes what you would put into args in general
],
pipe: true
}
Hey, this is nice work! I will take a look as soon as I can. Thanks again!
I'm going to close this as it's not really actionable for docketeer itself. The ergonomics don't quite work the same for me, but I can see how it is useful for someone who wants to avoid using docketeer or customise how docker is launched.
Thanks again for your input.
@frank-dspeed suggested this solution for tackling some of the issues: