|
| 1 | +FROM ubuntu:resolute |
| 2 | + |
| 3 | +ARG DEBIAN_FRONTEND=noninteractive |
| 4 | +ARG TZ=America/Los_Angeles |
| 5 | +ARG DOCKER_IMAGE_NAME_TEMPLATE="mcr.microsoft.com/playwright/java:v%version%-resolute" |
| 6 | + |
| 7 | +ENV LANG=C.UTF-8 |
| 8 | +ENV LC_ALL=C.UTF-8 |
| 9 | + |
| 10 | +# === INSTALL JDK and Maven === |
| 11 | + |
| 12 | +RUN apt-get update && \ |
| 13 | + apt-get install -y --no-install-recommends openjdk-25-jdk \ |
| 14 | + # Install utilities required for downloading browsers |
| 15 | + wget \ |
| 16 | + # Install utilities required for downloading driver |
| 17 | + unzip \ |
| 18 | + # For the MSEdge install script |
| 19 | + gpg && \ |
| 20 | + rm -rf /var/lib/apt/lists/* && \ |
| 21 | + # Create the pwuser |
| 22 | + useradd -m -s /bin/bash pwuser |
| 23 | + |
| 24 | +# Ubuntu 22.04 and earlier come with Maven 3.6.3 which fails with |
| 25 | +# Java 25, so we install latest Maven from Apache instead. |
| 26 | +RUN VERSION=3.9.12 && \ |
| 27 | + wget -O - https://archive.apache.org/dist/maven/maven-3/$VERSION/binaries/apache-maven-$VERSION-bin.tar.gz | tar zxfv - -C /opt/ && \ |
| 28 | + ln -s /opt/apache-maven-$VERSION/bin/mvn /usr/local/bin/ |
| 29 | + |
| 30 | +ARG PW_TARGET_ARCH |
| 31 | +ENV JAVA_HOME=/usr/lib/jvm/java-25-openjdk-${PW_TARGET_ARCH} |
| 32 | + |
| 33 | +# === BAKE BROWSERS INTO IMAGE === |
| 34 | + |
| 35 | +# Browsers will remain downloaded in `/ms-playwright`. |
| 36 | +# Note: make sure to set 777 to the registry so that any user can access |
| 37 | +# registry. |
| 38 | + |
| 39 | +ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright |
| 40 | + |
| 41 | +RUN mkdir /ms-playwright && \ |
| 42 | + mkdir /tmp/pw-java |
| 43 | + |
| 44 | +COPY . /tmp/pw-java |
| 45 | + |
| 46 | +RUN cd /tmp/pw-java && \ |
| 47 | + mvn install -D skipTests --no-transfer-progress && \ |
| 48 | + DEBIAN_FRONTEND=noninteractive mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI \ |
| 49 | + -D exec.args="install-deps" -f playwright/pom.xml --no-transfer-progress && \ |
| 50 | + mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI \ |
| 51 | + -D exec.args="install" -f playwright/pom.xml --no-transfer-progress && \ |
| 52 | + mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI \ |
| 53 | + -D exec.args="mark-docker-image '${DOCKER_IMAGE_NAME_TEMPLATE}'" -f playwright/pom.xml --no-transfer-progress && \ |
| 54 | + rm -rf /tmp/pw-java && \ |
| 55 | + chmod -R 777 $PLAYWRIGHT_BROWSERS_PATH |
0 commit comments