-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ci): Update ci to work with last version of puppeteer
- Loading branch information
Showing
7 changed files
with
193 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
FROM node:20-bookworm-slim | ||
|
||
USER root | ||
|
||
RUN mkdir -p /home/node/.cache/puppeteer | ||
|
||
# Puppeteer Chrome headless dependencies | ||
RUN apt-get update && apt-get install -y \ | ||
ca-certificates \ | ||
curl \ | ||
fonts-liberation \ | ||
libasound2 \ | ||
libatk-bridge2.0-0 \ | ||
libatk1.0-0 \ | ||
libc6 \ | ||
libcairo2 \ | ||
libcups2 \ | ||
libdbus-1-3 \ | ||
libexpat1 \ | ||
libfontconfig1 \ | ||
libgbm1 \ | ||
libgcc1 \ | ||
libglib2.0-0 \ | ||
libgtk-3-0 \ | ||
libnspr4 \ | ||
libnss3 \ | ||
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 \ | ||
lsb-release \ | ||
wget \ | ||
xdg-utils \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Install all dependencies needed for both services | ||
RUN npm install -g \ | ||
puppeteer \ | ||
eslint@8.38.0 \ | ||
eslint-plugin-html \ | ||
eslint-plugin-import \ | ||
eslint-plugin-node \ | ||
eslint-plugin-promise \ | ||
eslint-plugin-standard \ | ||
babel-loader \ | ||
@babel/core \ | ||
html-webpack-plugin \ | ||
webpack \ | ||
webpack-cli | ||
|
||
RUN usermod -a -G video,audio node | ||
|
||
# Create working directories for snippets | ||
RUN mkdir -p /var/snippets/web && \ | ||
mkdir -p /var/snippets/webpack | ||
|
||
# Set proper permissions | ||
RUN chown -R node:node /var/snippets/ | ||
RUN chown -R node:node /home/node/.cache/puppeteer | ||
|
||
USER node | ||
|
||
# Keep container running | ||
CMD ["tail", "-f", "/dev/null"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,60 @@ | ||
const puppeteer = require('puppeteer'); | ||
const puppeteer = require("puppeteer"); | ||
const renderedSnippetPath = process.argv[2]; | ||
|
||
const runInBrowser = async snippetPath => { | ||
const runInBrowser = async (snippetPath) => { | ||
let browser; | ||
|
||
try { | ||
// Install Chrome browser first | ||
const { execSync } = require('child_process'); | ||
execSync('npx puppeteer browsers install chrome', { stdio: 'inherit' }); | ||
|
||
browser = await puppeteer.launch({ | ||
dumpio: true, | ||
args: ['--no-sandbox'] | ||
headless: "new", | ||
// Remove executablePath to use the bundled Chromium | ||
args: [ | ||
"--no-sandbox", | ||
"--disable-setuid-sandbox", | ||
"--disable-gpu", | ||
"--disable-dev-shm-usage", | ||
], | ||
}); | ||
} catch (error) { | ||
console.error(error); | ||
return; | ||
console.error('Browser launch error:', error); | ||
process.exit(1); | ||
} | ||
|
||
try { | ||
const page = await browser.newPage(); | ||
|
||
page.on('error', err => { | ||
console.error(err); | ||
page.on("error", (err) => { | ||
console.error('Page error:', err); | ||
}); | ||
|
||
page.on('pageerror', err => { | ||
console.error(err); | ||
page.on("pageerror", (err) => { | ||
console.error('Page error:', err); | ||
}); | ||
|
||
page.on('console', msg => { | ||
console.log('Page console:', msg.text()); | ||
}); | ||
|
||
await page.goto(`file:${snippetPath}`, { | ||
waitUntil: 'networkidle0' | ||
waitUntil: "networkidle0", | ||
timeout: 30000, | ||
}); | ||
} catch (error) { | ||
console.error(error); | ||
console.error('Page processing error:', error); | ||
} finally { | ||
await browser.close(); | ||
if (browser) { | ||
await browser.close(); | ||
} | ||
} | ||
}; | ||
|
||
runInBrowser(renderedSnippetPath); | ||
if (!renderedSnippetPath) { | ||
console.error('Please provide a path to the snippet file'); | ||
process.exit(1); | ||
} | ||
|
||
runInBrowser(renderedSnippetPath); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.