chore: downgrade alpine version to 3.19 to avoid issue

This commit is contained in:
moonrailgun 2024-09-30 17:21:11 +08:00
parent 57ebaf6ad3
commit e6df595af8
2 changed files with 12 additions and 7 deletions

View File

@ -8,7 +8,8 @@ RUN apt update
RUN cd reporter && go build .
# Base ------------------------------
FROM node:20-alpine AS base
# The current Chromium version in Alpine 3.20 is causing timeout issues with Puppeteer. Downgrading to Alpine 3.19 fixes the issue. See #11640, #12637, #12189
FROM node:20-alpine3.19 AS base
RUN npm install -g pnpm@9.7.1
RUN apk add --update --no-cache python3 py3-pip g++ make
@ -38,9 +39,12 @@ ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser
ENV DEBUG=puppeteer:*
RUN apk add --no-cache \
udev \
ttf-freefont \
chromium
chromium \
nss \
freetype \
harfbuzz \
ca-certificates \
ttf-freefont
COPY . .

View File

@ -8,10 +8,9 @@ export async function generateLighthouse(url: string): Promise<Result> {
const browser = await puppeteer.launch({
// Set to false if you want to see the script in action.
headless: 'new',
args: ['--no-sandbox', '--single-process'],
args: ['--no-sandbox', '--single-process', '--disable-dev-shm-usage'],
defaultViewport: null,
ignoreDefaultArgs: ['--enable-automation'],
dumpio: true,
});
try {
@ -31,11 +30,13 @@ export async function generateLighthouse(url: string): Promise<Result> {
throw new Error('Lighthouse failed to generate report');
}
page.close({ runBeforeUnload: false });
await page.close({ runBeforeUnload: false });
const { lhr } = res;
return lhr;
} catch (err) {
throw err;
} finally {
await browser.close();
}