Created
April 11, 2022 11:51
-
-
Save uchagani/af1c2fcc9f66c1dcb21650a3b914473e to your computer and use it in GitHub Desktop.
Playwright Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM some-ubuntu-focal-based-image:latest | |
USER root | |
# === INSTALL JDK and Maven === | |
RUN apt-get update && \ | |
apt-get install -y --no-install-recommends \ | |
openjdk-11-jdk maven \ | |
# Install utilities required for downloading browsers | |
curl \ | |
# Install utilities required for downloading driver | |
unzip && \ | |
rm -rf /var/lib/apt/lists/* && \ | |
# Create the pwuser | |
adduser pwuser | |
ENV JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64 | |
# === 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 && \ | |
./playwright-scripts/get-playwright-source.sh && \ | |
./scripts/download_driver_for_all_platforms.sh && \ | |
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 && \ | |
rm -rf /tmp/pw-java && \ | |
chmod -R 777 $PLAYWRIGHT_BROWSERS_PATH | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PLAYWRIGHT_VERSION=$(cat playwright-scripts/PLAYWRIGHT-VERSION | |
URL=https://github.com/microsoft/playwright-java/archive/refs/tags/v$PLAYWRIGHT_VERSION.tar.gz | |
FILENAME=playwright.tar.gz | |
curl -sSLo $FILENAME $URL | |
tar -xzf $FILENAME | |
mv playwright-java-PLAYWRIGHT_VERSION/* . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1.20.1 |
You need to put that script in a playwright-scripts folder
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
tar -xzf $FILENAME not find get-playwright-source.sh,/bin/sh: 1: ./playwright-scripts/get-playwright-source.sh: not found