zoonru / puphpeteer

A Puppeteer bridge for PHP, supporting the entire API.
MIT License
139 stars 42 forks source link

Setting up puppeteer in a docker environment using sail #14

Open Joemires opened 2 months ago

Joemires commented 2 months ago

Hello guys! Please I need help with setting up my puppeteer in a docker environment I'm using laravel sail and will appreciate having a container with chrome setup where I can connect my puppeteer to, I have seen someone do it with node, something like this:

chrome:
    image: 'browserless/chrome'
    ports: 
        - '${BROWSERLESS_CHROME_PORT:-3000}:3000'
    networks:
        - sail
    environment:
        - CONNECTION_TIMEOUT=-1       

later in the code

const browser = await puppeteer.connect({
    browserWSEndpoint: "ws://chrome:3000",
});
dsebastien commented 4 weeks ago

I'm also curious about this. @Joemires, did you manage to make it work?

Joemires commented 4 weeks ago

Yes I did @dsebastien Your docker compose configuration

chrome:
    image: 'browserless/chrome'
    ports: 
        - '${BROWSERLESS_CHROME_PORT:-3000}:3000'
    networks:
        - sail
    environment:
        - CONNECTION_TIMEOUT=-1       

later in the code

$client = $puppeteer->connect([
    'browserWSEndpoint' => env('BROWSER_WS_ENDPOINT') ?: 'ws://localhost:300'
]);
Joemires commented 4 weeks ago

Yes I did @dsebastien Your docker compose configuration

chrome:
    image: 'browserless/chrome'
    ports: 
        - '${BROWSERLESS_CHROME_PORT:-3000}:3000'
    networks:
        - sail
    environment:
        - CONNECTION_TIMEOUT=-1       

later in the code

$client = $puppeteer->connect([
    'browserWSEndpoint' => env('BROWSER_WS_ENDPOINT') ?: 'ws://localhost:300'
]);

@dsebastien