Add continuous delivery for playwright-server docker image (#32522)

* Fix playwright-screenshots.sh script

gcut is a macos thing, use awk for stability

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Tweak playwright-screenshots.sh to pull image from ghcr before building

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Add missing dependency in playwright-common

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Add nx to prettierignore

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Add continuous delivery workflow for playwright-server image

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Switch to nx affected

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Prefix calls to nx with pnpm

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Pass GITHUB_TOKEN to nx affected

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Use explicit buildx builder

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Specify NX_DEFAULT_OUTPUT_STYLE

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Remove test trigger

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Fix image name

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

---------

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski
2026-02-19 16:28:51 +00:00
committed by GitHub
parent 38dbfb7a62
commit 0b0ac65149
8 changed files with 435 additions and 8 deletions
+1
View File
@@ -16,6 +16,7 @@
"playwright-screenshots-experimental": "playwright-screenshots.sh"
},
"devDependencies": {
"@playwright/test": "catalog:",
"wait-on": "^9.0.4"
}
}
@@ -2,19 +2,24 @@
set -e
# Handle symlinks here as we tend to be executed as an npm binary
SCRIPT_PATH=$(readlink -f "$0")
SCRIPT_DIR=$(dirname "$SCRIPT_PATH")
function build_image() {
local IMAGE_NAME="$1"
# Handle symlinks here as we tend to be executed as an npm binary
local SCRIPT_PATH=$(readlink -f "$0")
local SCRIPT_DIR=$(dirname "$SCRIPT_PATH")
echo "Building $IMAGE_NAME image in $SCRIPT_DIR"
docker build -t "$IMAGE_NAME" --build-arg "PLAYWRIGHT_VERSION=${IMAGE_NAME#*:}" "$SCRIPT_DIR"
}
IMAGE_NAME="element-web-playwright-server"
WS_PORT=3000
# Check the playwright version
PW_VERSION=$(npm exec --silent -- playwright --version | gcut -d" " -f2)
echo "Building $IMAGE_NAME:$PW_VERSION image in $SCRIPT_DIR"
PW_VERSION=$(pnpm --silent -- playwright --version | awk '{print $2}')
IMAGE_NAME="ghcr.io/element-hq/element-web/playwright-server:$PW_VERSION"
# Build the image
docker build -t "$IMAGE_NAME" --build-arg "PLAYWRIGHT_VERSION=$PW_VERSION" "$SCRIPT_DIR"
# Pull the image, failing that build the image
docker pull "$IMAGE_NAME" 2>/dev/null || build_image "$IMAGE_NAME"
# Start the playwright-server in docker
CONTAINER=$(docker run --network=host --rm -d -e PORT="$WS_PORT" "$IMAGE_NAME")
+31
View File
@@ -0,0 +1,31 @@
{
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"projectType": "library",
"root": "packages/playwright-common",
"targets": {
"docker:prebuild": {
"cache": true,
"command": "echo PLAYWRIGHT_VERSION=$(pnpm --silent -- playwright --version | awk '{print $2}') > .env.docker:build",
"inputs": [{ "runtime": "pnpm --silent -- playwright --version" }],
"outputs": ["{projectRoot}/.env.docker:build"],
"options": { "cwd": "packages/playwright-common" }
},
"docker:build": {
"executor": "@nx-tools/nx-container:build",
"dependsOn": ["docker:prebuild"],
"options": {
"load": true,
"engine": "docker",
"platforms": ["linux/amd64", "linux/arm64"],
"provenance": "true",
"sbom": true,
"build-args": ["PLAYWRIGHT_VERSION=$PLAYWRIGHT_VERSION"],
"context": "packages/playwright-common",
"metadata": {
"images": ["ghcr.io/element-hq/element-web/playwright-server"],
"tags": ["type=raw,enable=true,value=$PLAYWRIGHT_VERSION"]
}
}
}
}
}