Skip to content

Commit d71fee8

Browse files
committed
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'.
1 parent 06bb825 commit d71fee8

4 files changed

Lines changed: 8 additions & 12 deletions

File tree

scripts/download_driver.sh

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,16 @@ download() {
3737
DRIVER_VERSION=$(head -1 ./DRIVER_VERSION)
3838

3939
# Resolve the exact upstream commit that produced this driver version, so that the
40-
# bundled Node.js version matches the driver exactly. Query the npm registry over
41-
# HTTP instead of the npm CLI which is not available in the docker image build.
42-
VERSION_MANIFEST=$(mktemp)
43-
download "https://registry.npmjs.org/playwright/$DRIVER_VERSION" "$VERSION_MANIFEST"
44-
GIT_HEAD=$(grep -o '"gitHead"[[:space:]]*:[[:space:]]*"[0-9a-f]\{40\}"' "$VERSION_MANIFEST" | head -1 | grep -o '[0-9a-f]\{40\}')
45-
rm -f "$VERSION_MANIFEST"
40+
# bundled Node.js version matches the driver exactly.
41+
GIT_HEAD=$(npm view playwright@"$DRIVER_VERSION" gitHead)
4642
if [[ -z "$GIT_HEAD" ]]; then
4743
echo "Failed to resolve upstream commit (gitHead) for playwright@$DRIVER_VERSION"
4844
exit 1
4945
fi
5046

5147
# The Node.js version is kept in sync with the driver version in the upstream build script.
52-
BUILD_SCRIPT=$(mktemp)
53-
download "https://raw.githubusercontent.com/microsoft/playwright/$GIT_HEAD/utils/build/build-playwright-driver.sh" "$BUILD_SCRIPT"
54-
NODE_VERSION=$(sed -n 's/^NODE_VERSION="\([^"]*\)".*/\1/p' "$BUILD_SCRIPT")
55-
rm -f "$BUILD_SCRIPT"
48+
NODE_VERSION=$(curl -fsSL "https://raw.githubusercontent.com/microsoft/playwright/$GIT_HEAD/utils/build/build-playwright-driver.sh" \
49+
| sed -n 's/^NODE_VERSION="\([^"]*\)".*/\1/p')
5650
if [[ -z "$NODE_VERSION" ]]; then
5751
echo "Failed to determine Node.js version for playwright@$DRIVER_VERSION ($GIT_HEAD)"
5852
exit 1

utils/docker/Dockerfile.jammy

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ RUN mkdir /ms-playwright && \
4444
COPY . /tmp/pw-java
4545

4646
RUN cd /tmp/pw-java && \
47-
./scripts/download_driver.sh && \
4847
mvn install -D skipTests --no-transfer-progress && \
4948
DEBIAN_FRONTEND=noninteractive mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI \
5049
-D exec.args="install-deps" -f playwright/pom.xml --no-transfer-progress && \

utils/docker/Dockerfile.noble

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ RUN mkdir /ms-playwright && \
4444
COPY . /tmp/pw-java
4545

4646
RUN cd /tmp/pw-java && \
47-
./scripts/download_driver.sh && \
4847
mvn install -D skipTests --no-transfer-progress && \
4948
DEBIAN_FRONTEND=noninteractive mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI \
5049
-D exec.args="install-deps" -f playwright/pom.xml --no-transfer-progress && \

utils/docker/build.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,8 @@ fi
3434

3535
PW_TARGET_ARCH=$(echo $1 | cut -c3-)
3636

37+
# Assemble the driver on the host where npm is available; the Dockerfile picks
38+
# it up via `COPY . /tmp/pw-java`.
39+
../../scripts/download_driver.sh
40+
3741
docker build --platform "${PLATFORM}" --build-arg "PW_TARGET_ARCH=${PW_TARGET_ARCH}" -t "$3" -f "Dockerfile.$2" ../../

0 commit comments

Comments
 (0)