From c990db2bd5d6800a8debbf49433f9ac6175cac70 Mon Sep 17 00:00:00 2001 From: Wee Date: Sun, 17 Apr 2022 23:27:17 +0700 Subject: [PATCH] Replace Playwright server with a pre-built image --- changedetectionio/content_fetcher.py | 2 +- docker-compose.yml | 24 +++++++----------------- playwright/Dockerfile | 13 ------------- playwright/seccomp_profile.json | 12 ------------ playwright/server.js | 10 ---------- 5 files changed, 8 insertions(+), 53 deletions(-) delete mode 100644 playwright/Dockerfile delete mode 100644 playwright/seccomp_profile.json delete mode 100644 playwright/server.js diff --git a/changedetectionio/content_fetcher.py b/changedetectionio/content_fetcher.py index 00454e16..1a1139f6 100644 --- a/changedetectionio/content_fetcher.py +++ b/changedetectionio/content_fetcher.py @@ -103,7 +103,7 @@ class html_playwright(Fetcher): self.browser_type = os.getenv("PLAYWRIGHT_BROWSER_TYPE", 'chromium').strip('"') self.command_executor = os.getenv( "PLAYWRIGHT_DRIVER_URL", - 'ws://playwright-server:4444/playwright' + 'ws://playwright-chrome:3000/playwright' ).strip('"') # If any proxy settings are enabled, then we should setup the proxy object diff --git a/docker-compose.yml b/docker-compose.yml index 0914ed6f..0e6605fd 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -24,11 +24,7 @@ services: # https://selenium-python.readthedocs.io/api.html#module-selenium.webdriver.common.proxy # # Alternative Playwright URL, do not use "'s or 's! - # - PLAYWRIGHT_DRIVER_URL=ws://playwright-server:4444/playwright - # - # Alternative Playwright Browser Type, must match with PLAYWRIGHT_BROWSER_TYPE in the playwright-server service - # See https://playwright.dev/docs/browsers - # - PLAYWRIGHT_BROWSER_TYPE=chromium + # - PLAYWRIGHT_DRIVER_URL=ws://playwright-chrome:3000/playwright # # Playwright proxy settings playwright_proxy_server, playwright_proxy_bypass, playwright_proxy_username, playwright_proxy_password # @@ -71,18 +67,12 @@ services: # - /dev/shm:/dev/shm # restart: unless-stopped -# playwright-server: -# hostname: playwright-server -# build: ./playwright -# environment: -# - PLAYWRIGHT_PORT=4444 -# # Must match with PLAYWRIGHT_BROWSER_TYPE in the changedetection service -# - PLAYWRIGHT_BROWSER_TYPE=chromium -# ipc: host -# user: pwuser -# security_opt: -# - seccomp:./playwright/seccomp_profile.json -# restart: unless-stopped + # Used for fetching pages via Playwright+Chrome where you need Javascript support. + + playwright-chrome: + hostname: playwright-chrome + image: browserless/chrome + restart: unless-stopped volumes: changedetection-data: diff --git a/playwright/Dockerfile b/playwright/Dockerfile deleted file mode 100644 index 8dcd659e..00000000 --- a/playwright/Dockerfile +++ /dev/null @@ -1,13 +0,0 @@ -FROM mcr.microsoft.com/playwright:v1.20.0-focal - -WORKDIR /server -RUN npm install playwright -COPY server.js . - -ENV PLAYWRIGHT_PORT=4444 -ENV PLAYWRIGHT_BROWSER_TYPE=chromium -ENV PLAYWRIGHT_HEADLESS=true - -EXPOSE ${PLAYWRIGHT_PORT} - -CMD [ "node", "server.js" ] diff --git a/playwright/seccomp_profile.json b/playwright/seccomp_profile.json deleted file mode 100644 index bfeea36c..00000000 --- a/playwright/seccomp_profile.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "comment": "Allow create user namespaces", - "names": [ - "clone", - "setns", - "unshare" - ], - "action": "SCMP_ACT_ALLOW", - "args": [], - "includes": {}, - "excludes": {} -} diff --git a/playwright/server.js b/playwright/server.js deleted file mode 100644 index 9a730305..00000000 --- a/playwright/server.js +++ /dev/null @@ -1,10 +0,0 @@ -const playwright = require('playwright'); - -const port = parseInt(process.env.PLAYWRIGHT_PORT) || 4444; -const browserType = process.env.PLAYWRIGHT_BROWSER_TYPE?.toLowerCase() || 'chromium'; -const headless = process.env.PLAYWRIGHT_HEADLESS?.toLowerCase() === 'true' || true; -const wsPath = 'playwright'; -console.log('using port:', port, 'browser:', browserType, 'headless:', headless, 'wspath:', wsPath); - -const serverPromise = playwright[browserType].launchServer({ headless: headless, port: port, wsPath: wsPath }); -serverPromise.then(bs => console.log(bs.wsEndpoint()));