2023-04-12 19:41:41 +02:00
|
|
|
FROM ubuntu:jammy
|
|
|
|
|
|
|
|
ARG DEBIAN_FRONTEND=noninteractive
|
|
|
|
ARG TZ=America/Los_Angeles
|
|
|
|
ARG DOCKER_IMAGE_NAME_TEMPLATE="mcr.microsoft.com/playwright/java:v%version%-jammy"
|
|
|
|
|
2025-05-30 17:13:42 +02:00
|
|
|
ENV LANG=C.UTF-8
|
|
|
|
ENV LC_ALL=C.UTF-8
|
|
|
|
|
2023-04-12 19:41:41 +02:00
|
|
|
# === INSTALL JDK and Maven ===
|
|
|
|
|
|
|
|
RUN apt-get update && \
|
2024-02-12 12:47:19 -08:00
|
|
|
apt-get install -y --no-install-recommends openjdk-21-jdk \
|
2023-04-12 19:41:41 +02:00
|
|
|
# Install utilities required for downloading browsers
|
2024-10-01 09:39:38 +02:00
|
|
|
wget \
|
2023-04-12 19:41:41 +02:00
|
|
|
# Install utilities required for downloading driver
|
|
|
|
unzip \
|
|
|
|
# For the MSEdge install script
|
|
|
|
gpg && \
|
|
|
|
rm -rf /var/lib/apt/lists/* && \
|
|
|
|
# Create the pwuser
|
|
|
|
adduser pwuser
|
|
|
|
|
2024-02-12 12:47:19 -08:00
|
|
|
# Ubuntu 22.04 and earlier come with Maven 3.6.3 which fails with
|
|
|
|
# Java 21, so we install latest Maven from Apache instead.
|
2024-02-09 18:21:35 +01:00
|
|
|
RUN VERSION=3.9.6 && \
|
2024-10-01 09:39:38 +02:00
|
|
|
wget -O - https://archive.apache.org/dist/maven/maven-3/$VERSION/binaries/apache-maven-$VERSION-bin.tar.gz | tar zxfv - -C /opt/ && \
|
2023-04-12 19:41:41 +02:00
|
|
|
ln -s /opt/apache-maven-$VERSION/bin/mvn /usr/local/bin/
|
|
|
|
|
|
|
|
ARG PW_TARGET_ARCH
|
2024-02-12 12:47:19 -08:00
|
|
|
ENV JAVA_HOME=/usr/lib/jvm/java-21-openjdk-${PW_TARGET_ARCH}
|
2023-04-12 19:41:41 +02:00
|
|
|
|
|
|
|
# === BAKE BROWSERS INTO IMAGE ===
|
|
|
|
|
|
|
|
# Browsers will remain downloaded in `/ms-playwright`.
|
|
|
|
# Note: make sure to set 777 to the registry so that any user can access
|
|
|
|
# registry.
|
|
|
|
|
|
|
|
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
|
|
|
|
|
|
|
|
RUN mkdir /ms-playwright && \
|
|
|
|
mkdir /tmp/pw-java
|
|
|
|
|
|
|
|
COPY . /tmp/pw-java
|
|
|
|
|
|
|
|
RUN cd /tmp/pw-java && \
|
2024-06-25 08:34:20 -07:00
|
|
|
./scripts/download_driver.sh && \
|
2023-04-12 19:41:41 +02:00
|
|
|
mvn install -D skipTests --no-transfer-progress && \
|
|
|
|
DEBIAN_FRONTEND=noninteractive mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI \
|
|
|
|
-D exec.args="install-deps" -f playwright/pom.xml --no-transfer-progress && \
|
|
|
|
mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI \
|
|
|
|
-D exec.args="install" -f playwright/pom.xml --no-transfer-progress && \
|
|
|
|
mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI \
|
|
|
|
-D exec.args="mark-docker-image '${DOCKER_IMAGE_NAME_TEMPLATE}'" -f playwright/pom.xml --no-transfer-progress && \
|
|
|
|
rm -rf /tmp/pw-java && \
|
2023-11-15 19:54:37 +01:00
|
|
|
# Workaround for https://github.com/microsoft/playwright/issues/27313
|
|
|
|
# While the gstreamer plugin load process can be in-process, it ended up throwing
|
|
|
|
# an error that it can't have libsoup2 and libsoup3 in the same process because
|
|
|
|
# libgstwebrtc is linked against libsoup2. So we just remove the plugin.
|
|
|
|
if [ "$(uname -m)" = "aarch64" ]; then \
|
|
|
|
rm /usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstwebrtc.so; \
|
|
|
|
else \
|
|
|
|
rm /usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstwebrtc.so; \
|
|
|
|
fi && \
|
2023-04-12 19:41:41 +02:00
|
|
|
chmod -R 777 $PLAYWRIGHT_BROWSERS_PATH
|