I have a quarkus servicewhich use the Playwright
library for Java for web scraping tasks. On my windows host everything works fine when running the service on localhost, but when i run it on a openjdk:17.0.1-jdk-slim
docker image for deployment, i get the following error when executing code using Playwright
in the service:
com.microsoft.playwright.PlaywrightException: Error {
quarkus-service | message='
quarkus-service | ╔══════════════════════════════════════════════════════╗
quarkus-service | ║ Host system is missing dependencies to run browsers. ║
quarkus-service | ║ Missing libraries: ║
quarkus-service | ║ libsoup-2.4.so.1 ║
quarkus-service | ║ libgstreamer-1.0.so.0 ║
quarkus-service | ║ libgtk-3.so.0 ║
quarkus-service | ║ libgdk-3.so.0 ║
quarkus-service | ║ libcairo.so.2 ║
quarkus-service | ║ libepoxy.so.0 ║
quarkus-service | ║ libevent-2.1.so.7 ║
quarkus-service | ║ libopus.so.0 ║
quarkus-service | ║ libicui18n.so.67 ║
quarkus-service | ║ libicuuc.so.67 ║
quarkus-service | ║ libpango-1.0.so.0 ║
quarkus-service | ║ libharfbuzz.so.0 ║
quarkus-service | ║ libgdk_pixbuf-2.0.so.0 ║
quarkus-service | ║ libxml2.so.2 ║
quarkus-service | ║ libsqlite3.so.0 ║
quarkus-service | ║ libxslt.so.1 ║
quarkus-service | ║ liblcms2.so.2 ║
quarkus-service | ║ libwoff2dec.so.1.0.2 ║
quarkus-service | ║ libfontconfig.so.1 ║
quarkus-service | ║ libfreetype.so.6 ║
quarkus-service | ║ libharfbuzz-icu.so.0 ║
quarkus-service | ║ libgstallocators-1.0.so.0 ║
quarkus-service | ║ libgstapp-1.0.so.0 ║
quarkus-service | ║ libgstbase-1.0.so.0 ║
quarkus-service | ║ libgstpbutils-1.0.so.0 ║
quarkus-service | ║ libgstaudio-1.0.so.0 ║
quarkus-service | ║ libgsttag-1.0.so.0 ║
quarkus-service | ║ libgstvideo-1.0.so.0 ║
quarkus-service | ║ libgstgl-1.0.so.0 ║
quarkus-service | ║ libgstfft-1.0.so.0 ║
quarkus-service | ║ libjpeg.so.62 ║
quarkus-service | ║ libpng16.so.16 ║
quarkus-service | ║ libopenjp2.so.7 ║
quarkus-service | ║ libwebpdemux.so.2 ║
quarkus-service | ║ libwebp.so.6 ║
quarkus-service | ║ libenchant-2.so.2 ║
quarkus-service | ║ libsecret-1.so.0 ║
quarkus-service | ║ libhyphen.so.0 ║
quarkus-service | ║ libX11.so.6 ║
quarkus-service | ║ libXcomposite.so.1 ║
quarkus-service | ║ libXdamage.so.1 ║
quarkus-service | ║ libwayland-server.so.0 ║
quarkus-service | ║ libwayland-egl.so.1 ║
quarkus-service | ║ libwayland-client.so.0 ║
quarkus-service | ║ libmanette-0.2.so.0 ║
quarkus-service | ║ libgbm.so.1 ║
quarkus-service | ║ libdrm.so.2 ║
quarkus-service | ║ libatomic.so.1 ║
quarkus-service | ║ libxkbcommon.so.0 ║
quarkus-service | ║ libdbus-1.so.3 ║
quarkus-service | ║ libGLESv2.so.2 ║
quarkus-service | ║ libx264.so ║
quarkus-service | ╚══════════════════════════════════════════════════════╝
So it seems dependencies are missing on this image. For the NodeJS versions of the library, there appear to be e.g. NPM based utility functions for Playwright
to install these, but i don't see how to do this for Java. When i tried adding apt-get install
commands to my docker image build to manually install all the dependencies, they cannot be resolved.
I then found that there is a docker image for Playwright
for Java (https://hub.docker.com/_/microsoft-playwright-java), with the documentation stating that alpine based images are not supported for some reason and i assumed that is related (https://playwright.dev/java/docs/docker#usage). However, what find odd is that:
It does not state for which Java version this image uses, nor are there apparently different versions of the image offered. The Dockerfile is not even present to look at and see what it does on docker hub. I assume that Java must be installed on the image, otherwise you couldn't use the library - so do they use just a single image with a fixed java version? I saw that you can specify the version of
Playwright
when using a tag for the image, but what about the Java version?It states in the documentation that you are not supposed to use this image for production, only for test and development. Then how am i supposed to set up the docker image for production? Use an ubuntu base image, install the java version i need and then manually install all the dependencies? I am not sure i am missing something, so i wanted to see if this is the right (or only) way.