Last active
April 29, 2023 17:54
-
-
Save snmishra/9290d898122a05fd332289adf516c481 to your computer and use it in GitHub Desktop.
Slimmed Playwright image
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
})() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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