fix(adapters): copy vendor/ into the PHP asset stage so package CSS resolves - #467
Open
sudanese wants to merge 1 commit into
Open
fix(adapters): copy vendor/ into the PHP asset stage so package CSS resolves#467sudanese wants to merge 1 commit into
sudanese wants to merge 1 commit into
Conversation
…esolves The generated PHP Dockerfile compiles front-end assets in a separate Node stage that never receives the Composer vendor/ tree. Any Laravel app whose CSS pulls from a Composer package — Flux, Filament, or anything that ships a stylesheet — dies at `npm run build` with `Can't resolve ../../vendor/livewire/flux/dist/flux.css`. generatePhpDockerfile emits a `builder` (Composer) stage, an optional node:* asset stage, and the FrankenPHP runtime. The asset stage's `COPY . /workspace` brings the repo but not vendor/ (git-ignored, so never in the build context). resources/css/app.css @imports package CSS straight out of vendor/, and Tailwind 4 @source-scans it — both resolved by npm run build, which then fails. Copy vendor/ from the builder into the asset stage before the build. Reuses sourceDir so a rootDirectory monorepo sub-app copies the right path, and is guarded on installLine (vendor/ exists only when composer install ran).
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.
Summary
The generated PHP Dockerfile compiles front-end assets in a separate Node stage
that never receives the Composer
vendor/tree. Any Laravel app whose CSS pullsfrom a Composer package — Flux, Filament, or anything that ships a stylesheet —
therefore dies at
npm run buildwithCan't resolve ../../vendor/livewire/flux/dist/flux.css. Copyvendor/from thebuilder stage into the asset stage before the asset build runs.
Motivation
generatePhpDockerfile(packages/adapters/src/runtime/docker-build-plan.ts:199on
main) emits three stages: abuilder(Composer) stage, an optionalnode:*asset stage, and the FrankenPHP runtime. The asset stage is built at
:219-227:COPY . /workspacebrings the repo, butvendor/is git-ignored, so it is neverin the build context and never lands in this stage. That only breaks the asset
build, because of how a modern Laravel front-end resolves CSS:
resources/css/app.css@imports package stylesheets straight out of vendor,e.g.
@import '../../vendor/livewire/flux/dist/flux.css';@source '../../vendor/...'scans vendor for class usage.Both are resolved by
npm run build. Thevendor/tree exists only in thebuilderstage (that is wherecomposer installran), so the compile fails toresolve the import and the whole deploy fails — for every Flux project and any
Filament project with a custom theme (both
@importpackage CSS through theapp's Vite build), which is exactly the stack Openship's PHP recipe supports end
to end.
Fix: pull
vendor/from the builder into the asset stage before the build:It reuses
sourceDir(the same variable the builder WORKDIR and both runtimecopies already use), so a monorepo sub-app with
rootDirectoryset copies/workspace/<sub>/vendor, not a hardcoded path. It is guarded on the installstep:
vendor/exists in the builder only whencomposer installran, so a PHPproject with an asset build but no install command is left exactly as it was. The
runtime stage is untouched — it already copies the compiled docroot from the
asset stage.
Related issue
None — bug fix (per CONTRIBUTING, bug fixes go straight to a PR).
Changes
packages/adapters
src/runtime/docker-build-plan.ts— ingeneratePhpDockerfile, addCOPY --from=builder ${sourceDir}/vendor ${sourceDir}/vendorto the assetstage before the asset-build RUN line, guarded on
installLine.src/runtime/docker-build-plan.test.ts— one regression test in the existingPHP with a JS asset pipelineblock: the asset stage copies vendor from thebuilder, and does so before
npm run build.Nothing else is touched — no reformatting of lines I did not change.
Verification
RED first — the new test against the unfixed source (fix reverted, test kept):
GREEN — fix applied:
Typecheck:
I verified with the scoped
packages/adaptersrunner rather than rootbun run test: root currently fails onmainitself — #462 addedopenship@^0.5.0toapps/cli's deps, a turbo self-dependency unrelated to thischange.
bun formatis intentionally not run repo-wide: both touched filescarry pre-existing Prettier drift on lines I didn't change (confirmed on pristine
main), while the lines I added are Prettier-clean — so the diff stays scopedper the contributing guidelines.
Checklist
bun run test,bun run --cwd <workspace> lint, andbun formatall pass locallyHeads-up on CI: the workflow appears to fail at startup for all PRs since ~Aug 5, so this may show a red check unrelated to the change. Separately, root
bun run testcurrently fails onmain— #462 addedopenship@^0.5.0toapps/cli's deps (a turbo self-dependency) — so I verified with the scopedbun run --cwd packages/adapters test(1008 passed) +bun run --cwd packages/adapters lint(clean).