[Bug]: Cannot run program "/tmp/playwright-java-9325996558200189516/node": error=2, No such file or directory
Version
1.45.0
Steps to reproduce
Context
This is how we use Playwright in our application:
try (Playwright playwright = Playwright.create();
Browser browser = playwright.chromium().launch(new BrowserType.LaunchOptions().setHeadless(true));
Page page = browser.newContext().newPage()) {
// do something with page
} catch (Exception e) {
// throw e
}
However the JAR of our application became too large for our CI/CD pipeline due to Playwright - we noticed this is due to the drivers which includes for all supported OS, thus we did a Gradle workaround to only include the drivers we need (we used this as reference).
- In our
build.gradle, we repackageddriver-bundle.jarvia Gradle'sdistributionplugin - From 163 MB, we were able to size down the
driver-bundle.jarto 63 MB by only retaining the Linux drivers.
Expected behavior
When our application is run locally like via IDE, we are able to use Playwright without any issues.
Actual behavior
However if we run our app in Docker and invoked the API that uses Playwright, we encountered this error:
We then applied permissions to the /tmp/ folder via the Dockerfile
RUN chmod g+s /tmp/
RUN chown -R 1000:1000 /tmp/
but still we receive the same error. That's when we noticed that the playwright-java-*** folder below is actually only created during the first instance Playwright.create() is invoked, as it only initializes the driver by then.
We tried manually invoking the said node program inside the Docker instance and we received the same error as the logs.
What is the problem here? Is it because of our container using Alpine?
Additional context
No response
Environment
- Operating System: [Alpine Linux via Docker]
- Browser: [Chromium]
- Java Version: [17]
- Gradle Version: [8.1.1]
What is the problem here?
Hard to tell, you run some custom packages. The standard package seems to run fine in docker. If you want to skip the driver extraction step, you can pass 'playwright.cli.dir' property pointing to already installed driver's location which is probably your best bet. There is an open request for splitting the driver which is tracked in https://github.com/microsoft/playwright-java/issues/1196, you can upvote that issue.
If you think this is an issue with standard Playwright packages, please file a new issue with a self-contained repro.
Is it because of our container using Alpine?
Alpine is not supported officially: https://playwright.dev/java/docs/intro#system-requirements
The standard package seems to run fine in docker. If you want to skip the driver extraction step, you can pass 'playwright.cli.dir' property pointing to already installed driver's location which is probably your best bet.
@yury-s How do we pre install a driver? I can't seem to locate the instructions for this, kindly please point me to any guide. Thank you.
I faced the same problem. You can install on the Alpine Chrome and Node, and it should work https://stackoverflow.com/a/75581837/12446589