From 06bb8258b900346c361f6599ed4c9db2755466e8 Mon Sep 17 00:00:00 2001 From: Yury Semikhatsky Date: Fri, 12 Jun 2026 13:02:15 -0700 Subject: [PATCH 1/2] fix(docker): download driver without npm and curl The docker image build has neither npm nor curl, only wget. Resolve the upstream gitHead via the npm registry HTTP API and fetch the upstream build script through the existing wget-or-curl helper. --- scripts/download_driver.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/scripts/download_driver.sh b/scripts/download_driver.sh index dba7f75d2..a888ae9e8 100755 --- a/scripts/download_driver.sh +++ b/scripts/download_driver.sh @@ -37,16 +37,22 @@ download() { DRIVER_VERSION=$(head -1 ./DRIVER_VERSION) # Resolve the exact upstream commit that produced this driver version, so that the -# bundled Node.js version matches the driver exactly. -GIT_HEAD=$(npm view playwright@"$DRIVER_VERSION" gitHead) +# bundled Node.js version matches the driver exactly. Query the npm registry over +# HTTP instead of the npm CLI which is not available in the docker image build. +VERSION_MANIFEST=$(mktemp) +download "https://registry.npmjs.org/playwright/$DRIVER_VERSION" "$VERSION_MANIFEST" +GIT_HEAD=$(grep -o '"gitHead"[[:space:]]*:[[:space:]]*"[0-9a-f]\{40\}"' "$VERSION_MANIFEST" | head -1 | grep -o '[0-9a-f]\{40\}') +rm -f "$VERSION_MANIFEST" if [[ -z "$GIT_HEAD" ]]; then echo "Failed to resolve upstream commit (gitHead) for playwright@$DRIVER_VERSION" exit 1 fi # The Node.js version is kept in sync with the driver version in the upstream build script. -NODE_VERSION=$(curl -fsSL "https://raw.githubusercontent.com/microsoft/playwright/$GIT_HEAD/utils/build/build-playwright-driver.sh" \ - | sed -n 's/^NODE_VERSION="\([^"]*\)".*/\1/p') +BUILD_SCRIPT=$(mktemp) +download "https://raw.githubusercontent.com/microsoft/playwright/$GIT_HEAD/utils/build/build-playwright-driver.sh" "$BUILD_SCRIPT" +NODE_VERSION=$(sed -n 's/^NODE_VERSION="\([^"]*\)".*/\1/p' "$BUILD_SCRIPT") +rm -f "$BUILD_SCRIPT" if [[ -z "$NODE_VERSION" ]]; then echo "Failed to determine Node.js version for playwright@$DRIVER_VERSION ($GIT_HEAD)" exit 1 From d71fee8aa585878b76e7326508967fd0e3f5226b Mon Sep 17 00:00:00 2001 From: Yury Semikhatsky Date: Fri, 12 Jun 2026 13:09:00 -0700 Subject: [PATCH 2/2] fix(docker): assemble driver on the host instead of inside docker build Revert the npm-free download in favor of calling download_driver.sh from build.sh; the Dockerfile picks up the assembled driver via 'COPY . /tmp/pw-java'. --- scripts/download_driver.sh | 14 ++++---------- utils/docker/Dockerfile.jammy | 1 - utils/docker/Dockerfile.noble | 1 - utils/docker/build.sh | 4 ++++ 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/scripts/download_driver.sh b/scripts/download_driver.sh index a888ae9e8..dba7f75d2 100755 --- a/scripts/download_driver.sh +++ b/scripts/download_driver.sh @@ -37,22 +37,16 @@ download() { DRIVER_VERSION=$(head -1 ./DRIVER_VERSION) # Resolve the exact upstream commit that produced this driver version, so that the -# bundled Node.js version matches the driver exactly. Query the npm registry over -# HTTP instead of the npm CLI which is not available in the docker image build. -VERSION_MANIFEST=$(mktemp) -download "https://registry.npmjs.org/playwright/$DRIVER_VERSION" "$VERSION_MANIFEST" -GIT_HEAD=$(grep -o '"gitHead"[[:space:]]*:[[:space:]]*"[0-9a-f]\{40\}"' "$VERSION_MANIFEST" | head -1 | grep -o '[0-9a-f]\{40\}') -rm -f "$VERSION_MANIFEST" +# bundled Node.js version matches the driver exactly. +GIT_HEAD=$(npm view playwright@"$DRIVER_VERSION" gitHead) if [[ -z "$GIT_HEAD" ]]; then echo "Failed to resolve upstream commit (gitHead) for playwright@$DRIVER_VERSION" exit 1 fi # The Node.js version is kept in sync with the driver version in the upstream build script. -BUILD_SCRIPT=$(mktemp) -download "https://raw.githubusercontent.com/microsoft/playwright/$GIT_HEAD/utils/build/build-playwright-driver.sh" "$BUILD_SCRIPT" -NODE_VERSION=$(sed -n 's/^NODE_VERSION="\([^"]*\)".*/\1/p' "$BUILD_SCRIPT") -rm -f "$BUILD_SCRIPT" +NODE_VERSION=$(curl -fsSL "https://raw.githubusercontent.com/microsoft/playwright/$GIT_HEAD/utils/build/build-playwright-driver.sh" \ + | sed -n 's/^NODE_VERSION="\([^"]*\)".*/\1/p') if [[ -z "$NODE_VERSION" ]]; then echo "Failed to determine Node.js version for playwright@$DRIVER_VERSION ($GIT_HEAD)" exit 1 diff --git a/utils/docker/Dockerfile.jammy b/utils/docker/Dockerfile.jammy index e66319a80..0f290946f 100644 --- a/utils/docker/Dockerfile.jammy +++ b/utils/docker/Dockerfile.jammy @@ -44,7 +44,6 @@ RUN mkdir /ms-playwright && \ COPY . /tmp/pw-java RUN cd /tmp/pw-java && \ - ./scripts/download_driver.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 && \ diff --git a/utils/docker/Dockerfile.noble b/utils/docker/Dockerfile.noble index e0173bd6e..6b8b4bac8 100644 --- a/utils/docker/Dockerfile.noble +++ b/utils/docker/Dockerfile.noble @@ -44,7 +44,6 @@ RUN mkdir /ms-playwright && \ COPY . /tmp/pw-java RUN cd /tmp/pw-java && \ - ./scripts/download_driver.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 && \ diff --git a/utils/docker/build.sh b/utils/docker/build.sh index 074d22b19..ed2653078 100755 --- a/utils/docker/build.sh +++ b/utils/docker/build.sh @@ -34,4 +34,8 @@ fi PW_TARGET_ARCH=$(echo $1 | cut -c3-) +# Assemble the driver on the host where npm is available; the Dockerfile picks +# it up via `COPY . /tmp/pw-java`. +../../scripts/download_driver.sh + docker build --platform "${PLATFORM}" --build-arg "PW_TARGET_ARCH=${PW_TARGET_ARCH}" -t "$3" -f "Dockerfile.$2" ../../