Skip to content
This repository was archived by the owner on Aug 30, 2022. It is now read-only.

Commit 4f4a396

Browse files
committed
Fix puppeteer not running on linux
Signed-off-by: Tomás Migone <[email protected]>
1 parent 0aa0d75 commit 4f4a396

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

Dockerfile.template

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ WORKDIR /usr/src
44

55
RUN install_packages chromium
66

7+
COPY token.json .
8+
COPY credentials.json .
79
COPY package*.json ./
810
RUN npm install
911

@@ -21,6 +23,8 @@ WORKDIR /usr/src
2123

2224
RUN install_packages chromium
2325

26+
COPY token.json .
27+
COPY credentials.json .
2428
COPY package*.json ./
2529
COPY --from=builder /usr/src/build /usr/src/build
2630
RUN npm install --production

src/browser.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { Browser, Page } from 'puppeteer';
22
import puppeteer from 'puppeteer-extra';
33
import StealthPlugin = require('puppeteer-extra-plugin-stealth');
4-
import * as os from 'os';
54

65
puppeteer.use(StealthPlugin());
76

7+
const RUNNING_ALPINE = !!process.env.RUNNING_ALPINE;
8+
89
export async function newBrowser(): Promise<Browser> {
910
const puppeteerOptions = {
1011
headless: true,
@@ -24,7 +25,8 @@ export async function newBrowser(): Promise<Browser> {
2425
defaultViewport: { height: 912, width: 1480 },
2526
};
2627

27-
if (os.platform() === 'linux') {
28+
if (RUNNING_ALPINE) {
29+
console.log('Running on Alpine, altering puppeteer chromium path...');
2830
/* @ts-ignore */
2931
puppeteerOptions.executablePath = '/usr/bin/chromium-browser';
3032
}

0 commit comments

Comments
 (0)