playwright not working

It’s working locally, but with fly.io I get an error.

DockerFile

FROM zenika/alpine-chrome:with-node

ENV PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD 1
ENV PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH='/usr/bin/chromium-browser'
WORKDIR /usr/src/app
COPY --chown=chrome package.json package-lock.json ./
RUN npm install
COPY --chown=chrome . ./
ENTRYPOINT ["tini", "--"]
CMD ["node", "main.mjs"]
2022-08-31T08:51:01.292 app[1a284686] nrt [info] node:internal/process/esm_loader:91

2022-08-31T08:51:01.292 app[1a284686] nrt [info] internalBinding('errors').triggerUncaughtException(

2022-08-31T08:51:01.292 app[1a284686] nrt [info] ^

2022-08-31T08:51:01.292 app[1a284686] nrt [info] browserType.launch: Executable doesn't exist at /app/.cache/ms-playwright/chromium-901522/chrome-linux/chrome

2022-08-31T08:51:01.292 app[1a284686] nrt [info] ╔═════════════════════════════════════════════════════════════════════════╗

2022-08-31T08:51:01.292 app[1a284686] nrt [info] β•‘ Looks like Playwright Test or Playwright was just installed or updated. β•‘

2022-08-31T08:51:01.292 app[1a284686] nrt [info] β•‘ Please run the following command to download new browsers: β•‘

2022-08-31T08:51:01.292 app[1a284686] nrt [info] β•‘ β•‘

2022-08-31T08:51:01.292 app[1a284686] nrt [info] β•‘ npx playwright install β•‘

2022-08-31T08:51:01.292 app[1a284686] nrt [info] β•‘ β•‘

2022-08-31T08:51:01.292 app[1a284686] nrt [info] β•‘ <3 Playwright Team β•‘

2022-08-31T08:51:01.292 app[1a284686] nrt [info] β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

2022-08-31T08:51:01.292 app[1a284686] nrt [info] at file:///workspace/main.mjs:30:32 {

2022-08-31T08:51:01.292 app[1a284686] nrt [info] name: 'Error'

2022-08-31T08:51:01.292 app[1a284686] nrt [info] }

Hi!

I recall some people tried to setup it here, maybe this helps:

I used this as a reference and it worked fine.
Thank you.

FROM zenika/alpine-chrome:with-playwright

USER root
ENV NODE_ENV=production
WORKDIR /src

COPY package*.json ./
RUN npm install

COPY . .
EXPOSE 8080
CMD ["node" , "main.mjs"]
2 Likes

Hey @green, I’m also trying to deploy a small app that uses playwright.

I tried using the Dockerfile you posted above, but didn’t have any luck. Did you have to do anything else to get playwright working?

Here is the Dockerfile (unchanged except for the CMD) and fly.toml I am using:

FROM zenika/alpine-chrome:with-playwright

USER root
ENV NODE_ENV=production
WORKDIR /src

COPY package*.json ./
RUN npm install

COPY . .
EXPOSE 8080
CMD ["node" , "server.js"]
# fly.toml file generated for spring-water-3752 on 2022-09-16T11:10:48-04:00

app = "spring-water-3752"
kill_signal = "SIGINT"
kill_timeout = 5
processes = []

[build]
  dockerfile = "Dockerfile"

[env]
  PORT = "8080"

[experimental]
  allowed_public_ports = []
  auto_rollback = true

[[services]]
  http_checks = []
  internal_port = 8080
  processes = ["app"]
  protocol = "tcp"
  script_checks = []
  [services.concurrency]
    hard_limit = 25
    soft_limit = 20
    type = "connections"

  [[services.ports]]
    force_https = true
    handlers = ["http"]
    port = 80

  [[services.ports]]
    handlers = ["tls", "http"]
    port = 443

  [[services.tcp_checks]]
    grace_period = "1s"
    interval = "15s"
    restart_limit = 0
    timeout = "2s"

I have changed LaunchOptions besides that

const browser = await chromium.launch({
  executablePath: "/usr/bin/chromium-browser",
  args: [
    '--disable-dev-shm-usage',
    '--disable-setuid-sandbox',
    '--no-sandbox'
  ],
  chromiumSandbox: false
});