From 69b0a354b32bc083def3a83c6bb0668c6c926730 Mon Sep 17 00:00:00 2001 From: Vincent Hardouin Date: Mon, 7 Oct 2024 13:49:22 +0200 Subject: [PATCH] feat: add prod docker compose --- .dockerignore | 8 +++ Dockerfile | 26 ++++++++ compose.yaml | 6 ++ config.js | 5 +- package-lock.json | 115 ++++++++++++---------------------- package.json | 2 +- prod.compose.yaml | 53 ++++++++++++++++ sample.env | 4 +- src/infrastructure/Browser.js | 7 ++- 9 files changed, 147 insertions(+), 79 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 prod.compose.yaml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..40d4bb8 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,8 @@ +sample.env +.env +README.md +eslint.config.js +.github +docs +node_modules +tests diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..67efa15 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,26 @@ +ARG NODE_VERSION=20.16.0 + +FROM node:${NODE_VERSION}-alpine as builder +WORKDIR /app + +# Download dependencies as a separate step to take advantage of Docker's caching. +# Leverage a cache mount to /root/.npm to speed up subsequent builds. +# Leverage a bind mounts to package.json and package-lock.json to avoid having to copy them into +# into this layer. +RUN --mount=type=bind,source=package.json,target=package.json \ + --mount=type=bind,source=package-lock.json,target=package-lock.json \ + --mount=type=cache,target=/root/.npm \ + npm ci + +COPY . . + +FROM node:${NODE_VERSION}-alpine + +WORKDIR /app +USER node + +COPY --from=builder /app . + +ARG PORT=4000 +ENV PORT $PORT +EXPOSE $PORT \ No newline at end of file diff --git a/compose.yaml b/compose.yaml index 2278a0c..d78915d 100644 --- a/compose.yaml +++ b/compose.yaml @@ -9,3 +9,9 @@ services: POSTGRES_DB: ucpa_facilitator env_file: - .env + + chrome: + image: ghcr.io/browserless/chromium + container_name: chrome + ports: + - '3000:3000' diff --git a/config.js b/config.js index 9267351..bb501ff 100644 --- a/config.js +++ b/config.js @@ -15,7 +15,7 @@ function getParsedJson(environmentVariable) { function buildConfiguration() { const config = { environment: env.NODE_ENV || 'development', - port: env.PORT || 3000, + port: env.PORT || 4000, baseURL: env.BASE_URL || 'http://example.net', secret: env.SECRET, logging: { @@ -60,6 +60,9 @@ function buildConfiguration() { passTypeIdentifier: env.PASS_TYPE_IDENTIFIER, teamIdentifier: env.PASS_TEAM_IDENTIFIER, }, + browser: { + browserWSEndpoint: env.BROWSER_WS_ENDPOINT, + }, }; if (config.environment === 'test') { config.logging.enabled = false; diff --git a/package-lock.json b/package-lock.json index 7acb7b4..2e6022e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,7 +21,7 @@ "passkit-generator": "^3.1.11", "pg": "^8.13.0", "pino": "^9.4.0", - "puppeteer": "^23.4.0" + "puppeteer-core": "^23.5.0" }, "devDependencies": { "@antfu/eslint-config": "^3.6.1", @@ -174,6 +174,7 @@ "version": "7.24.7", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.24.7.tgz", "integrity": "sha512-BcYH1CVJBO9tvyIZ2jVeXgSIMvGZ2FDRvDdOIVQyuklNKSsx+eppDEBq/g47Ayw+RqNFE+URvOShmf+f/qwAlA==", + "dev": true, "license": "MIT", "dependencies": { "@babel/highlight": "^7.24.7", @@ -198,6 +199,7 @@ "version": "7.24.7", "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.24.7.tgz", "integrity": "sha512-rR+PBcQ1SMQDDyF6X0wxtG8QyLCgUB0eRAGguqRLfkCA87l7yAP7ehq8SNj96OOGTO8OBV70KhuFYcIkHXOg0w==", + "dev": true, "license": "MIT", "engines": { "node": ">=6.9.0" @@ -207,6 +209,7 @@ "version": "7.24.7", "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.24.7.tgz", "integrity": "sha512-EStJpq4OuY8xYfhGVXngigBJRWxftKX9ksiGDnmlY3o7B/V7KIAc9X4oiK87uPJSc/vs5L869bem5fhZa8caZw==", + "dev": true, "license": "MIT", "dependencies": { "@babel/helper-validator-identifier": "^7.24.7", @@ -222,6 +225,7 @@ "version": "3.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, "license": "MIT", "dependencies": { "color-convert": "^1.9.0" @@ -234,6 +238,7 @@ "version": "2.4.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, "license": "MIT", "dependencies": { "ansi-styles": "^3.2.1", @@ -248,6 +253,7 @@ "version": "1.9.3", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, "license": "MIT", "dependencies": { "color-name": "1.1.3" @@ -257,12 +263,14 @@ "version": "1.1.3", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", + "dev": true, "license": "MIT" }, "node_modules/@babel/highlight/node_modules/escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", + "dev": true, "license": "MIT", "engines": { "node": ">=0.8.0" @@ -272,6 +280,7 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", + "dev": true, "license": "MIT", "engines": { "node": ">=4" @@ -281,6 +290,7 @@ "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, "license": "MIT", "dependencies": { "has-flag": "^3.0.0" @@ -1234,9 +1244,9 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "22.5.5", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.5.5.tgz", - "integrity": "sha512-Xjs4y5UPO/CLdzpgR6GirZJx36yScjh73+2NlLlkFRSoQN8B0DpfXPdZGnvVmLRLOsqDpOfTNv7D9trgGhmOIA==", + "version": "22.7.4", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.7.4.tgz", + "integrity": "sha512-y+NPi1rFzDs1NdQHHToqeiX2TIS79SWEAw9GYhkkx8bD0ChpfqC+n2j5OXOCpzfojBEBt6DnEnnG9MY0zk1XLg==", "license": "MIT", "optional": true, "dependencies": { @@ -1699,6 +1709,7 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true, "license": "Python-2.0" }, "node_modules/assertion-error": { @@ -1733,9 +1744,9 @@ } }, "node_modules/b4a": { - "version": "1.6.6", - "resolved": "https://registry.npmjs.org/b4a/-/b4a-1.6.6.tgz", - "integrity": "sha512-5Tk1HLk6b6ctmjIkAcU/Ujv/1WqiDl0F0JdRCR80VsOcUlHcu7pWeWRlOqQLHfDEsVx9YH/aif5AG4ehoCtTmg==", + "version": "1.6.7", + "resolved": "https://registry.npmjs.org/b4a/-/b4a-1.6.7.tgz", + "integrity": "sha512-OnAYlL5b7LEkALw87fUVafQw5rVR9RjwGd4KUwNQ6DrrNmaVaUCgLipfVlzrPQ4tWOR9P0IXGNOx50jYCCdSJg==", "license": "Apache-2.0" }, "node_modules/balanced-match": { @@ -1746,9 +1757,9 @@ "license": "MIT" }, "node_modules/bare-events": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/bare-events/-/bare-events-2.4.2.tgz", - "integrity": "sha512-qMKFd2qG/36aA4GwvKq8MxnPgCQAmBWmSyLWsJcbn8v03wvIPQ/hG1Ms8bPzndZxMDoHpxez5VOS+gC9Yi24/Q==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/bare-events/-/bare-events-2.5.0.tgz", + "integrity": "sha512-/E8dDe9dsbLyh2qrZ64PEPadOQ0F4gbl1sUJOrmph7xOiIxfY8vwab/4bFLh4Y88/Hk/ujKcrQKc+ps0mv873A==", "license": "Apache-2.0", "optional": true }, @@ -1960,6 +1971,7 @@ "version": "3.1.0", "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", + "dev": true, "license": "MIT", "engines": { "node": ">=6" @@ -2104,9 +2116,9 @@ } }, "node_modules/chromium-bidi": { - "version": "0.6.5", - "resolved": "https://registry.npmjs.org/chromium-bidi/-/chromium-bidi-0.6.5.tgz", - "integrity": "sha512-RuLrmzYrxSb0s9SgpB+QN5jJucPduZQ/9SIe76MDxYJuecPW5mxMdacJ1f4EtgiV+R0p3sCkznTMvH0MPGFqjA==", + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/chromium-bidi/-/chromium-bidi-0.8.0.tgz", + "integrity": "sha512-uJydbGdTw0DEUjhoogGveneJVWX/9YuqkWePzMmkBYwtdAqo5d3J/ovNKFr+/2hWXYmYCr6it8mSSTIj6SS6Ug==", "license": "Apache-2.0", "dependencies": { "mitt": "3.0.1", @@ -2241,32 +2253,6 @@ "url": "https://opencollective.com/core-js" } }, - "node_modules/cosmiconfig": { - "version": "9.0.0", - "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-9.0.0.tgz", - "integrity": "sha512-itvL5h8RETACmOTFc4UfIyB2RfEHi71Ax6E/PivVxq9NseKbOWpeyHEOIbmAw1rs8Ak0VursQNww7lf7YtUwzg==", - "license": "MIT", - "dependencies": { - "env-paths": "^2.2.1", - "import-fresh": "^3.3.0", - "js-yaml": "^4.1.0", - "parse-json": "^5.2.0" - }, - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/d-fischer" - }, - "peerDependencies": { - "typescript": ">=4.9.5" - }, - "peerDependenciesMeta": { - "typescript": { - "optional": true - } - } - }, "node_modules/cron": { "version": "3.1.7", "resolved": "https://registry.npmjs.org/cron/-/cron-3.1.7.tgz", @@ -2597,19 +2583,11 @@ "url": "https://github.com/fb55/entities?sponsor=1" } }, - "node_modules/env-paths": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/env-paths/-/env-paths-2.2.1.tgz", - "integrity": "sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A==", - "license": "MIT", - "engines": { - "node": ">=6" - } - }, "node_modules/error-ex": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", + "dev": true, "license": "MIT", "dependencies": { "is-arrayish": "^0.2.1" @@ -4156,6 +4134,7 @@ "version": "3.3.0", "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", + "dev": true, "license": "MIT", "dependencies": { "parent-module": "^1.0.0", @@ -4233,6 +4212,7 @@ "version": "0.2.1", "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", "integrity": "sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==", + "dev": true, "license": "MIT" }, "node_modules/is-binary-path": { @@ -4400,12 +4380,14 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true, "license": "MIT" }, "node_modules/js-yaml": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "dev": true, "license": "MIT", "dependencies": { "argparse": "^2.0.1" @@ -4454,6 +4436,7 @@ "version": "2.3.1", "resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz", "integrity": "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==", + "dev": true, "license": "MIT" }, "node_modules/json-schema-traverse": { @@ -4742,6 +4725,7 @@ "version": "1.2.4", "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz", "integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==", + "dev": true, "license": "MIT" }, "node_modules/linkify-it": { @@ -6283,6 +6267,7 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", + "dev": true, "license": "MIT", "dependencies": { "callsites": "^3.0.0" @@ -6319,6 +6304,7 @@ "version": "5.2.0", "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz", "integrity": "sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==", + "dev": true, "license": "MIT", "dependencies": { "@babel/code-frame": "^7.0.0", @@ -6528,6 +6514,7 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.0.tgz", "integrity": "sha512-TQ92mBOW0l3LeMeyLV6mzy/kWr8lkd/hp3mTg7wYK7zJhuBStmGMBG0BdeDZS/dZx1IukaX6Bk11zcln25o1Aw==", + "dev": true, "license": "ISC" }, "node_modules/picomatch": { @@ -6813,35 +6800,14 @@ "node": ">=6" } }, - "node_modules/puppeteer": { - "version": "23.4.0", - "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-23.4.0.tgz", - "integrity": "sha512-FxgFFJI7NAsX8uebiEDSjS86vufz9TaqERQHShQT0lCbSRI3jUPEcz/0HdwLiYvfYNsc1zGjqY3NsGZya4PvUA==", - "hasInstallScript": true, - "license": "Apache-2.0", - "dependencies": { - "@puppeteer/browsers": "2.4.0", - "chromium-bidi": "0.6.5", - "cosmiconfig": "^9.0.0", - "devtools-protocol": "0.0.1342118", - "puppeteer-core": "23.4.0", - "typed-query-selector": "^2.12.0" - }, - "bin": { - "puppeteer": "lib/cjs/puppeteer/node/cli.js" - }, - "engines": { - "node": ">=18" - } - }, "node_modules/puppeteer-core": { - "version": "23.4.0", - "resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-23.4.0.tgz", - "integrity": "sha512-fqkIP5FOcb38jfBj/OcBz1wFaI9nk40uQKSORvnXws6wCbep2dg8yxZ3ddJxBIfQsxoiEOvnrykFinUScrB/ew==", + "version": "23.5.0", + "resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-23.5.0.tgz", + "integrity": "sha512-+5ed+625GuQ2emRHqYec8khT9LP14FWzv8hYl0HiM6hnnlNzdVU9uDJIPHeCPLIWxq15ost9MeF8kBk4R3eiFw==", "license": "Apache-2.0", "dependencies": { "@puppeteer/browsers": "2.4.0", - "chromium-bidi": "0.6.5", + "chromium-bidi": "0.8.0", "debug": "^4.3.7", "devtools-protocol": "0.0.1342118", "typed-query-selector": "^2.12.0", @@ -7153,6 +7119,7 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", + "dev": true, "license": "MIT", "engines": { "node": ">=4" @@ -7840,7 +7807,7 @@ "version": "5.6.2", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.2.tgz", "integrity": "sha512-NW8ByodCSNCwZeghjN3o+JX5OFH0Ojg6sadjEKY4huZ52TqbJTJnDo5+Tw98lSy63NZvi4n+ez5m2u5d4PkZyw==", - "devOptional": true, + "dev": true, "license": "Apache-2.0", "peer": true, "bin": { diff --git a/package.json b/package.json index 7da175b..71ac9d0 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "passkit-generator": "^3.1.11", "pg": "^8.13.0", "pino": "^9.4.0", - "puppeteer": "^23.4.0" + "puppeteer-core": "^23.5.0" }, "devDependencies": { "@antfu/eslint-config": "^3.6.1", diff --git a/prod.compose.yaml b/prod.compose.yaml new file mode 100644 index 0000000..fb387b6 --- /dev/null +++ b/prod.compose.yaml @@ -0,0 +1,53 @@ +services: + postgres-ucpa: + image: postgres:15.8-alpine + container_name: ucpa-postgres + networks: + - back + ports: + - '${UCPA_DATABASE_PORT_API:-5466}:5432' + volumes: + - ./postgres-data:/var/lib/postgresql/data + environment: + POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} + POSTGRES_USER: ${POSTGRES_USER} + POSTGRES_DB: ucpa_facilitator + env_file: + - .env + + chrome: + image: ghcr.io/browserless/chromium + container_name: chrome + networks: + - back + + app-ucpa: + build: + context: . + container_name: app-ucpa + depends_on: + - postgres-ucpa + - chrome + command: > + sh -c "npm run db:migrate && npm start" + networks: + - back + - web + volumes: + - ./certs:/app/certs + environment: + NODE_ENV: production + env_file: + - .env + labels: + traefik.enable: true + traefik.docker.network: web + traefik.http.routers.ucpa.rule: Host(`${URL}`) + traefik.http.routers.ucpa.entrypoints: websecure + traefik.http.routers.ucpa.tls: true + traefik.http.routers.ucpa.tls.certresolver: letsencrypt + +networks: + back: + web: + external: true diff --git a/sample.env b/sample.env index 6cee90d..049a030 100644 --- a/sample.env +++ b/sample.env @@ -59,4 +59,6 @@ CALENDAR_NAME=ucpa CALENDAR_ID=5f67a0f9-3c63-4be5-b86a-c064ebcea491 PASS_TYPE_IDENTIFIER= -PASS_TEAM_IDENTIFIER= \ No newline at end of file +PASS_TEAM_IDENTIFIER= + +BROWSER_WS_ENDPOINT=ws://localhost:3000/ \ No newline at end of file diff --git a/src/infrastructure/Browser.js b/src/infrastructure/Browser.js index b1f1ab0..8fc2a68 100644 --- a/src/infrastructure/Browser.js +++ b/src/infrastructure/Browser.js @@ -1,5 +1,6 @@ import { env } from 'node:process'; -import puppeteer from 'puppeteer'; +import puppeteer from 'puppeteer-core'; +import { config } from '../../config.js'; export class Browser { constructor(browser, page) { @@ -11,7 +12,9 @@ export class Browser { if (env.NODE_ENV === 'test') { return; } - const browser = await puppeteer.launch({ headless: true }); + const browser = await puppeteer.connect({ + browserWSEndpoint: config.browser.browserWSEndpoint, + }); const page = await browser.newPage(); const customUA = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:127.0) Gecko/20100101 Firefox/127.0'; await page.setUserAgent(customUA);