Skip to content

Commit

Permalink
few fix and update puppeteer v
Browse files Browse the repository at this point in the history
  • Loading branch information
yoramshai committed Dec 29, 2024
1 parent 208a1cd commit 195656e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 14 deletions.
25 changes: 12 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
# everything below sets up and runs lighthouse
FROM node:16-bullseye-slim
FROM node:20-bullseye-slim

# Install latest chrome dev package and fonts to support major charsets (Chinese, Japanese, Arabic, Hebrew, Thai and a few others)
# Note: this installs the necessary libs to make the bundled version of Chromium that Puppeteer
# installs, work.
RUN 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-unstable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf dumb-init \
--no-install-recommends \
&& rm -rf /var/lib/apt/lists/*
# Install Chromium and other dependencies
RUN apt-get update \
&& apt-get install -y chromium fonts-ipafont-gothic fonts-wqy-zenhei \
fonts-thai-tlwg fonts-kacst fonts-freefont-ttf dumb-init \
--no-install-recommends \
&& rm -rf /var/lib/apt/lists/*

ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
ENV CHROME_PATH "google-chrome-unstable"
# Set environment variables for Puppeteer
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
ENV CHROME_PATH=/usr/bin/chromium
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium

USER node

Expand All @@ -31,7 +30,7 @@ COPY --chown=node:node src ./src
COPY --chown=node:node tsconfig.json .
RUN yarn build

ENV NODE_ENV production
ENV NODE_ENV=production

# prune out dev dependencies now that build has completed
RUN yarn install --production
Expand Down
13 changes: 12 additions & 1 deletion src/api/audits/methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,18 @@ async function runAudit(
try {
logger.debug('Launching Chrome with Puppeteer ...');
const puppeteerOptions: puppeteer.PuppeteerNodeLaunchOptions = {
args: [`--remote-debugging-port=${chromePort}`, '--no-sandbox'],
args: [
`--remote-debugging-port=${chromePort}`,
"--no-sandbox",
"--disable-dev-shm-usage",
"--disable-setuid-sandbox",
"--disable-accelerated-2d-canvas",
"--no-first-run",
"--no-zygote",
"--single-process",
"--disable-gpu",
],

};
if (chromePath) {
puppeteerOptions.executablePath = chromePath;
Expand Down
2 changes: 2 additions & 0 deletions src/db/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

/*
* Copyright 2020 Spotify AB
*
Expand Down Expand Up @@ -42,6 +43,7 @@ async function getSchema(conn: DbConnectionType) {

export async function awaitDbConnection(
conn: DbConnectionType,
// @ts-ignore
options: Options = { maxRetryTime: 10000 },
): Promise<void> {
logger.debug('awaiting db connection...');
Expand Down

0 comments on commit 195656e

Please sign in to comment.