feat(preview-service): allow chromium exec path & puppeteer user data dir to be configured (#2462)

This commit is contained in:
Iain Sproat 2024-07-02 10:39:19 +01:00 коммит произвёл GitHub
Родитель 80d987d4d4
Коммит 4bc42d59ab
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
2 изменённых файлов: 16 добавлений и 2 удалений

Просмотреть файл

@ -0,0 +1,9 @@
PREVIEWS_HEADED='true'
CHROMIUM_EXECUTABLE_PATH='/usr/bin/google-chrome-stable'
USER_DATA_DIR='/tmp/puppeteer'
PG_CONNECTION_STRING='postgres://speckle:speckle@127.0.0.1/speckle'
POSTGRES_MAX_CONNECTIONS_PREVIEW_SERVICE='2'
PROMETHEUS_METRICS_PORT='9094'
PORT='3001'
LOG_LEVEL='info'
LOG_PRETTY='true'

Просмотреть файл

@ -9,6 +9,10 @@ const { reduce } = require('lodash')
const shouldBeHeadless = process.env.PREVIEWS_HEADED !== 'true'
const getChromiumExecutablePath = () =>
process.env.CHROMIUM_EXECUTABLE_PATH || '/usr/bin/google-chrome-stable'
const getPuppeteerUserDataDir = () => process.env.USER_DATA_DIR || '/tmp/puppeteer'
async function pageFunction(objectUrl) {
waitForAnimation = async (ms = 70) =>
await new Promise((resolve) => {
@ -60,8 +64,9 @@ async function pageFunction(objectUrl) {
async function getScreenshot(objectUrl, boundLogger = logger) {
const launchParams = {
headless: shouldBeHeadless,
userDataDir: '/tmp/puppeteer',
executablePath: '/usr/bin/google-chrome-stable',
userDataDir: getPuppeteerUserDataDir(),
executablePath: getChromiumExecutablePath(),
protocolTimeout: 3600_000,
// we trust the web content that is running, so can disable the sandbox
// disabling the sandbox allows us to run the docker image without linux kernel privileges
args: ['--no-sandbox', '--disable-setuid-sandbox', '--disable-dev-shm-usage']