[compile-extension] Fetch Docker assets lazily - #3598
Merged
Conversation
adamziel
marked this pull request as ready for review
May 4, 2026 23:00
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR makes @php-wasm/compile-extension runnable outside a WordPress/wordpress-playground checkout by lazily fetching only the minimal Docker-related assets it needs, and adds a CLI mode to pre-build the required Docker images.
Changes:
- Added an
isomorphic-git-based sparse fetcher + caching for required PHP.wasm Docker build assets. - Introduced
--prepare-imageto build the base/extension images without compiling an extension. - Added CI + tests to verify the published-package boundary (no bundled Playground assets; lazy fetch works).
Reviewed changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/php-wasm/compile-extension/vite.config.ts | Externalizes isomorphic-git modules for the bundle/runtime. |
| packages/php-wasm/compile-extension/tests/test-lazy-docker-asset-fetch.sh | End-to-end check that built package fetches assets lazily and doesn’t ship them. |
| packages/php-wasm/compile-extension/src/git-sparse-checkout.ts | Implements sparse blob fetch via git-upload-pack and isomorphic-git object reads. |
| packages/php-wasm/compile-extension/src/docker.ts | Makes docker context resolution async and adds lazy asset fetching fallback. |
| packages/php-wasm/compile-extension/src/docker.spec.ts | Adds unit tests for docker context selection and ref resolution. |
| packages/php-wasm/compile-extension/src/docker-assets.ts | Adds asset list, cache layout, ref selection, and sparse fetch integration. |
| packages/php-wasm/compile-extension/src/compile.ts | Adds image preparation flow and updates compile flow for async context + docker check. |
| packages/php-wasm/compile-extension/src/cli.ts | Adds --prepare-image mode and adjusts argument validation + workspace detection. |
| packages/php-wasm/compile-extension/project.json | Removes docker-asset copying during build; adds clean + a new Nx test target. |
| packages/php-wasm/compile-extension/package.json | Adds isomorphic-git dependency. |
| packages/php-wasm/compile-extension/README.md | Documents lazy fetch behavior, caching, and --prepare-image. |
| .github/workflows/ci.yml | Runs the new lazy-fetch verification step before integration fixtures. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What it does
Makes
@php-wasm/compile-extensionusable without checking outWordPress/wordpress-playground.Before this PR, you've needed to get the PHP build context from the Playground repository before using the compilation extensions.
After this PR, the package lazily sparse-fetches the minimal PHP.wasm Docker asset set it needs. Published packages fetch from the matching Playground tag, e.g. package
3.1.27fetchesv3.1.27. Playground workspace/dev runs use local assets when present and otherwise fetch fromtrunk.Rationale
The README said the package only needs Docker and Node, but the CLI still expected
packages/php-wasm/compileto exist locally. Downstream CI had to sparse clone Playground as a workaround.Implementation
Added an
isomorphic-gitbased sparse fetcher for the required Dockerfiles, base-image scripts, PHP patches, and extension build script. Added--prepare-imageso workflows can prepare the package-owned Docker image before compiling a final extension.The package does not ship Playground-built dependency archives. Consumers should vendor/build their own Emscripten archives and pass them via
--extra-cflags/--extra-ldflags.Testing instructions
Run:
This target builds the npm package, verifies the dry-run tarball does not include Playground Docker assets, runs the built CLI from outside the repo, verifies the cache was fetched from the matching tag, and uses a fake Docker binary to stop before a real image build.
The full compile-extension CI job now runs this package-boundary check before the Docker-backed integration fixtures.