Skip to content

Instantly share code, notes, and snippets.

@snmishra
Last active April 29, 2023 17:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save snmishra/9290d898122a05fd332289adf516c481 to your computer and use it in GitHub Desktop.
Save snmishra/9290d898122a05fd332289adf516c481 to your computer and use it in GitHub Desktop.
Slimmed Playwright image
FROM node:18-slim as builder
ARG PLAYWRIGHT_VERSION
ARG PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
RUN npx playwright@${PLAYWRIGHT_VERSION} install chromium
FROM node:18-slim as runner
ARG PLAYWRIGHT_VERSION
ARG PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
COPY --from=builder /ms-playwright /ms-playwright
RUN npx playwright@${PLAYWRIGHT_VERSION} install-deps chromium
USER node
WORKDIR /home/node
RUN npm install http-proxy playwright-core@${PLAYWRIGHT_VERSION}
COPY start.* .
EXPOSE 3000 8000 9222
CMD ["./start.sh"]
const pw = require('playwright')
const httpProxy = require('http-proxy')
;(async () => {
const browserServer = await pw.chromium.launchServer({ port: 3000 })
const wsEndpoint = browserServer.wsEndpoint()
httpProxy
.createProxyServer({ target: wsEndpoint, ws: true, ignorePath: true })
.listen(8000)
console.log(wsEndpoint)
return wsEndpoint
})()
#!/bin/sh
node "$(dirname $0)/start.js"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment