Harden the Hazelnut image and streamline environment commands - #2
Open
balintbrews wants to merge 1 commit into
Open
Harden the Hazelnut image and streamline environment commands#2balintbrews wants to merge 1 commit into
balintbrews wants to merge 1 commit into
Conversation
Tested end to end in containers: Drupal install, Drush, PHPUnit unit and kernel tests, PHPStan, PHPCBF, Playwright, Cypress, the Canvas editor with built assets and via the Vite dev server (canvas_vite), Turborepo builds with cache reuse, and the VNC bridge. - Move the Canvas checkout physically into web/modules/contrib/canvas and leave a symlink at the workspace path. Canvas tooling (its Composer scripts, cypress.config.js, @drupal-canvas/test-utils, and @drupal/playwright) locates Drupal by walking up parent directories, which cannot work from a checkout outside the Drupal tree. - Append vendor/bin to PATH instead of prepending, so the phpunit, phpcs, and phpstan wrappers are not shadowed after composer install. - Serve the site from the docroot: PHP's built-in server keeps its launch working directory, which broke docroot-relative includes such as canvas_headless's jsonapi_resources impostor classes. - Run PHP_CLI_SERVER_WORKERS=8; the single-threaded default serialized asset requests. - Run npm from inside the workspace root; npm --prefix through the workspace symlink breaks npm's workspace resolution and prunes packages. - Bake the Cypress binary and Playwright Chromium into the image, pinned via build arguments. - Add a VNC bridge (Xvfb, fluxbox, x11vnc, noVNC on port 6080) started by canvas-env-start, mirroring the DDEV setup. - Rewrite the phpcs and phpstan wrappers to invoke the environment root's binaries directly with Canvas's configuration. - Remove the n wrapper; use npm from the target directories directly. - Ship both pre-install-cmd hook scripts so composer.json stays byte-identical to the repository root copy, replacing the jq rewrite. - Set BASE_URL, DB_URL, DRUPAL_ROOT_CORE, and DRUPAL_TEST_DRUPAL_ROOT for the Cypress and Playwright configurations, and add PHP's SQLite driver. - Make ui install npm dependencies when they are absent, so the site-install --ui flow works on a fresh checkout. - Add an AGENTS.md for agents working inside the container. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B8Mgvp7U1cs88rTE5dvPEH
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.
Hardens the Hazelnut image based on end-to-end testing in containers, and streamlines the environment commands.
Bugs found by testing, and their fixes
cypress.config.js,@drupal-canvas/test-utils,@drupal/playwright) locates Drupal by walking up parent directories, which cannot work when the checkout lives outside the Drupal tree;composer run phpstan, Cypress config load, and Playwright fixtures all failedcanvas-env-initnow moves the checkout physically intoweb/modules/contrib/canvasand leaves a symlink at the workspace path (bind-mounted checkouts fall back to the old linking with a warning)PATHputvendor/binfirst, so aftercomposer installPHPUnit's own binary shadowed thephpunitwrapper (same forphpcs,phpstan); the wrappers silently never ranvendor/bintoPATHinstead of prependingcanvas_headless'sjsonapi_resourcesimpostor classes made the editor return a 500)canvas-env-startnow serves from the docrootphp -Sis single-threaded by default, serializing asset requestsPHP_CLI_SERVER_WORKERS=8npm --prefixthrough the workspace symlink breaks npm's workspace resolution: it pruned 2,145 packages and rewrotepackage-lock.jsonBASE_URLand a Drupal core path, Playwright fixtures need the Drupal root, and e2e site installs need a database URL; none were setBASE_URL,DRUPAL_ROOT_CORE,DRUPAL_TEST_DRUPAL_ROOT, andDB_URLinto the image, plusphp8.3-sqlite3for SQLite-based flowssite-install --uifollowed byuifailed on a fresh checkout because npm dependencies were never installed in that flowuiinstalls dependencies whennode_modulesis absentImprovements
/opt/cypress-cache,/opt/ms-playwright), pinned with build arguments that mirror what the Canvas repository resolves. The commands assume they are available; no downloads at runtime.canvas-env-startruns Xvfb, fluxbox, x11vnc, and noVNC (port 6080), mirroring the DDEV setup.cypress --openandplaywright --headedsessions can be watched athttp://localhost:6080/vnc.html.composer.json: the image ships bothpre-install-cmdhook scripts (check-repo.sh, plus a no-opcheck-repo-mercury.sh), so the image'scomposer.jsonstays byte-identical to the repository root copy and the build-timejqrewrite is gone.bin/cleanup:nremoved;playwrightis now a thin passthrough toplaywright test;cypressgained--openfor VNC sessions and dismisses the first-run welcome screen;phpcs/phpstaninvoke the environment root's binaries directly with Canvas's configuration;site-installlost dead code (vendor/bin/dr).AGENTS.mdadded to the build context, written for agents working inside the container.Verified in containers
canvas_vite+ui), checked in a real browser.composer installwith both hook scripts; Drush 13.7 (status,uli,cr,php:eval).site-install,site-install --stark, andsite-install --ui.lint(36 tasks) and package tests pass; container rebuilds hit the cache (FULL TURBO), and cache artifacts are portable between host and container when theVITE_*environment matches.>=22.19.0 <23 || >=24.5.0; the image's Node 24 satisfies every workspace.Notes
node --no-opt). The UI build that takes ~12 seconds natively takes ~45 minutes emulated, and JS-bundling-heavy steps (Cypress runs) are similarly affected. This is a local-testing caveat on Mac hosts, not an image issue; a native arm64 image variant would remove it.🤖 Generated with Claude Code
https://claude.ai/code/session_01B8Mgvp7U1cs88rTE5dvPEH