diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index b0f48648..5c05584d 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -94,11 +94,12 @@ jobs: env: IMAGE: ${{ steps.compute.outputs.image }} PLAYWRIGHT_VERSION: ${{ steps.compute.outputs.playwright-version }} - run: docker build - --file tests/integration/fixtures/files/playwright/Dockerfile - --build-arg "PLAYWRIGHT_VERSION=${PLAYWRIGHT_VERSION}" - --tag "${IMAGE}" - tests/integration/fixtures/files/playwright + run: docker buildx bake + --load + --file docker-bake.hcl + --set "*.tags=${IMAGE}" + --set "*.args.PLAYWRIGHT_VERSION=${PLAYWRIGHT_VERSION}" + playwright-browser # Docker only uploads the parts that the registry does not have already - name: Push the image diff --git a/docker-bake.hcl b/docker-bake.hcl index 2aa68a53..9e903bf8 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -1,5 +1,5 @@ // Copyright 2025 New Vector Ltd -// Copyright 2025 Element Creations Ltd +// Copyright 2025-2026 Element Creations Ltd // // SPDX-License-Identifier: AGPL-3.0-only @@ -11,3 +11,13 @@ target "matrix-tools" { dockerfile = "Dockerfile" context = "./matrix-tools" } + +// The image the browser server runs in. The integration tests drive it +// (tests/integration/fixtures/playwright.py). +// Unlike matrix-tools it does not inherit the metadata target: it is not published under +// the regular tags. Its name and tag are computed by image_reference(). The tests and CI +// pass them with --set when they build the image, together with the playwright version. +target "playwright-browser" { + dockerfile = "Dockerfile" + context = "./tests/integration/fixtures/files/playwright" +} diff --git a/tests/integration/fixtures/playwright.py b/tests/integration/fixtures/playwright.py index 5c23d8e9..39222f8e 100644 --- a/tests/integration/fixtures/playwright.py +++ b/tests/integration/fixtures/playwright.py @@ -33,6 +33,7 @@ except ImportError: # locally, with the same name and tag. IMAGE_NAME = "ghcr.io/element-hq/ess-helm/playwright-browser" DOCKERFILE = Path(__file__).parent / "files" / "playwright" / "Dockerfile" +REPO_ROOT = Path(__file__).parent.parent.parent.parent.resolve() # The path where the test CA certificate is mounted in the container. The start script of # the image installs it in the browser before the browser server starts (see the Dockerfile). @@ -70,11 +71,14 @@ def _ensure_image() -> str: try: docker.pull(reference) except Exception: - docker.build( - context_path=DOCKERFILE.parent, - file=DOCKERFILE, - tags=[reference], - build_args={"PLAYWRIGHT_VERSION": package_version("playwright")}, + docker.buildx.bake( + files=REPO_ROOT / "docker-bake.hcl", + targets="playwright-browser", + set={ + "*.tags": reference, + "*.args.PLAYWRIGHT_VERSION": package_version("playwright"), + }, + load=True, ) return reference