Repository navigation
Support JavaScript monorepos in Dockerfile generation (incl. pnpm + PublishAsNpmScript) - #16839
David Fowler (davidfowl) wants to merge 1 commit into
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 16839Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 16839" |
|
Update on the pnpm deploy direction: We should not force pnpm 10 for every workspace Docker build. After checking Corepack behavior and real pnpm monorepos, the safer rule is to treat the root That means the generated Dockerfile should route pnpm workspace For the explicit pnpm 10+ path, Aspire should validate during the publish/build pipeline that injectWorkspacePackages: trueThis avoids silently overriding projects that are pinned to pnpm 8/9 (or have no explicit pin), while still using pnpm 10+ non-legacy deploy when the repo has explicitly opted into that package-manager major and workspace setting. This is important because |
|
Will it support NX monorepos ? Or should it be considered as different implementation support ? |
|
On Nx monorepos: this PR does not add Nx-specific project-graph/deploy integration. The support here is package-manager/workspace based: Aspire discovers the JavaScript workspace package and generates Dockerfile commands that run the configured package scripts from the workspace root. So an Nx repo can work if the app package scripts encapsulate the right Nx commands, for example |
8c4146f to
c887cc6
Compare
c887cc6 to
9119e4a
Compare
Co-authored-by: Copilot <[email protected]>
9119e4a to
c8e99d9
Compare
|
Re-running the failed jobs in the CI workflow for this pull request because 1 job was identified as retry-safe transient failures in the CI run attempt.
|
|
❌ CLI E2E Tests failed — 109 passed, 2 failed, 2 unknown (commit ❌ Failed Tests
View all recordings
📹 Recordings uploaded automatically from CI run #26676501988 |
…2164) ## Description Graduate Next.js hosting and the existing JavaScript publishing APIs from `ASPIREJAVASCRIPT001`, so consumers no longer need experimental-warning suppressions for these scenarios. Retain all APIs, signatures, generated artifacts, runtime behavior, and the existing **release/17.0** build-validation behavior. - Remove the markers from `AddNextJsApp`, `NextJsAppResource`, `DisableBuildValidation`, both `PublishAsStaticWebsite` overloads and their internal adapter/core, `PublishAsStaticWebsiteOptions`, `PublishAsNodeServer`, and `PublishAsPackageScript`. - Remove now-unnecessary suppressions from existing consumer tests and playgrounds. Those tests now compile and exercise the APIs without suppressing this diagnostic. - Document the stable publishing shapes and existing Next.js prerequisites in the integration README. Generated `api/*.cs` baselines remain untouched. - This PR does not graduate Deno or future APIs that might reuse `ASPIREJAVASCRIPT001`. Deno was independently graduated on the release target; the merge preserves that change. Fixes # (issue) ### User-facing usage Existing calls remain unchanged; C# callers can remove their `ASPIREJAVASCRIPT001` suppressions: ```csharp builder.AddNextJsApp("frontend", "../frontend"); builder.AddViteApp("static-site", "../static-site") .PublishAsStaticWebsite(); ``` The existing exported TypeScript API names remain unchanged: ```typescript await builder.addNextJsApp("frontend", "../frontend"); await builder.addViteApp("static-site", "../static-site") .publishAsStaticWebsite(); ``` ### Publishing contract evaluation This PR proposes graduation of the current contracts, not a new framework-wide support guarantee or a claim of prior maintainer approval: | Shape | Contract retained | |---|---| | Static website | Build the configured output directory (`dist` by default), copy it to YARP's static-file root, and preserve optional API proxying, prefix stripping, and endpoint selection. Unmatched-path behavior is unchanged. | | Node server | Copy the selected built output and run the specified entry point directly with Node.js. | | Package script | Run the selected script with the configured package manager and its runtime dependencies; preserve the distinct Node/Bun/Deno image-generation paths. | | Next.js | Preserve standalone output: `public/`, `.next/standalone/`, and `.next/static/`, with `node server.js` in the runtime image. A `public/` directory remains required. | Next.js configuration inspection remains a static heuristic, not execution of `next.config.*`. `DisableBuildValidation()` still supports dynamically supplied configuration without changing the required output. Existing user Dockerfiles and explicit entrypoint overrides retain their current treatment. **Release-specific boundary:** release/17.0 has the older resource-annotation validation pipeline, not main's container `AddPublishValidation` integration. This PR does not port that integration or its Azure graph tests, and does not claim release verification of validation-before-image-build behavior across Azure Container Apps/App Service or excluded-resource handling. The README omits those main-specific guarantees. Validation behavior on the release branch is unchanged by this PR. The workspace proposal #16839 and SPA-fallback proposal #21871 are not duplicate graduation PRs and are not included here. In particular, this PR does not approve their new APIs or change the current static-site fallback default. Any later change to these now-stable contracts still needs its own compatibility review. ### Release branch repair Replayed only the original stabilization commit `c1b09a678919c92a682ce7bf48dd8d299bf0abd0`, using its verified original-main fork point `793dfe6e254fe050af24cb7bcfba214066dcaab8`, onto release/17.0 at `9a97ab889bfb731de74ead0280be279ffdd000bf`. No release-to-head history range was cherry-picked. The sole conflict was a suppression removal in `JavaScriptPublishValidationTests.cs`, a test file absent from release. Kept it absent instead of importing main features/tests. A second documentation-only commit removes unsupported release validation guarantees. The replay initially contained **2 scoped commits and 11 files**, rather than unrelated main history. On November 15, merged the release target at `a509f094e0ee87d17dc0e1cc9bca84f7ca2623da` to resolve reported conflicts. Kept both the Next.js/publishing documentation and the target's independently graduated Deno documentation; removed both obsolete suppressions from the conflicted Deno test file. The target-relative diff remains 11 scoped files. No history rewrite or additional API/runtime behavior changes. ### Introduction attribution @davidfowl introduced the Next.js resource, validation opt-out, static-website options/helpers, Node-server helper, and original package-script helper in #15736 ([introducing commit](96a3327)). The package-script helper was subsequently renamed from `PublishAsNpmScript` to `PublishAsPackageScript` in #17382 ([rename commit](5384db2)), also by @davidfowl. Attribution was checked against introducing code history and the GitHub commit/PR author identities, not the merge committer or latest editor. No attribution uncertainty identified; these are mentions, not reviewer assignments. ### Validation **Current release/17.0-based branch:** - **Passed again after the November 15 conflict resolution, 338 tests, 0 failed, 0 skipped**, including the project build, with the exact focused command below. **Passed:** `git diff --cached --check origin/release/17.0` before committing the merge. The earlier CI `Final Results` failure was an aggregate dependent-job failure also reported on the target by the native PR finisher; it is not worked around in this PR. - **Passed, 338 tests, 0 failed, 0 skipped:** existing consumer/API tests, generated artifact snapshots, and release's existing Next.js validation cases. The negative pipeline test also emitted expected failures from building its deliberately invalid npm fixture; the test run exited 0. ```bash dotnet test --project tests/Aspire.Hosting.JavaScript.Tests/Aspire.Hosting.JavaScript.Tests.csproj --no-launch-profile -- --filter-class '*.AddJavaScriptAppTests' --filter-class '*.AddViteAppTests' --filter-class '*.NodeJsPublicApiTests' --filter-class '*.AddNodeAppTests' --filter-class '*.AddDenoAppTests' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true' ``` - **Passed:** `git diff --check origin/release/17.0...HEAD`. No generated snapshot or API baseline changes. - **Not run on release:** main-only `JavaScriptPublishValidationTests` (absent), successful live framework image builds, CLI multi-framework deployment E2E, live Azure deployment, or a full repository suite. The passing release tests do not establish end-to-end deployment success for every framework or main's stronger validation-graph guarantees. **Historical main-based validation only; not release validation:** - **Passed, 114 baseline tests before changes:** ```bash dotnet test --project tests/Aspire.Hosting.JavaScript.Tests/Aspire.Hosting.JavaScript.Tests.csproj --no-launch-profile -- --filter-class '*.AddJavaScriptAppTests' --filter-class '*.AddViteAppTests' --filter-class '*.NodeJsPublicApiTests' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true' ``` - **Passed, 344 tests after changes on main:** ```bash dotnet test --project tests/Aspire.Hosting.JavaScript.Tests/Aspire.Hosting.JavaScript.Tests.csproj --no-launch-profile -- --filter-class '*.AddJavaScriptAppTests' --filter-class '*.AddViteAppTests' --filter-class '*.NodeJsPublicApiTests' --filter-class '*.AddNodeAppTests' --filter-class '*.AddDenoAppTests' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true' ``` - **Passed, 2 Azure validation-graph tests on main:** ```bash dotnet test --project tests/Aspire.Hosting.Azure.Tests/Aspire.Hosting.Azure.Tests.csproj --no-launch-profile -- --filter-class '*.JavaScriptPublishValidationTests' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true' ``` ## Checklist - Is this feature complete? - [x] Yes. Ready to ship. - [ ] No. Follow-up changes expected. - Are you including unit tests for the changes and scenario tests if relevant? - [x] Yes - [ ] No - Did you add public API? - [ ] Yes - If yes, did you have an API Review for it? - [ ] Yes - [ ] No - Did you add `<remarks />` and `<code />` elements on your triple slash comments? - [ ] Yes - [ ] No - [x] No - Does the change make any security assumptions or guarantees? - [ ] Yes - If yes, have you done a threat model and had a security review? - [ ] Yes - [ ] No - [x] No --------- Co-authored-by: Maddy Montaquila <[email protected]> Co-authored-by: Copilot App <[email protected]>
Description
Adds first-class Dockerfile generation support for JavaScript monorepos using npm, pnpm, yarn, and bun workspaces. This lets users publish JavaScript apps that live under a workspace root without hand-writing Dockerfiles or copying sibling package manifests into the app directory.
User-facing usage
Users can mark a JavaScript resource as a workspace member with the experimental
WithWorkspaceRoot(...)API (ASPIREJAVASCRIPT001):When publishing, Aspire now uses the workspace root as the Docker build context, copies root and member package manifests for better Docker layer caching, installs dependencies at the workspace root, and runs package-manager-specific workspace commands for the selected app.
For pnpm workspaces using
PublishAsNpmScript, Aspire now usespnpm deployinstead of the generic prod-deps overlay. Explicit pnpm 10+ projects use modern deploy wheninjectWorkspacePackages: trueis configured; pnpm 8/9/unknown versions usenpm_config_force_legacy_deploy=truefor compatibility.Implementation notes
WithWorkspaceRoot(...)API and workspace annotations for JavaScript app resources.package.json,packageManager/devEngines.packageManager, andpnpm-workspace.yaml.DistributedApplicationException, not as AppHost construction failures.CreateLayout.Validation
Targeted local validation:
Result: 107/107 passed.
Additional coverage added:
corepack enable.aspire do build.Related to #14416. This PR covers workspace-aware Dockerfile/publish support for yarn and pnpm workspaces, but does not add the proposed
AddYarnWorkspaceApp/AddPnpmWorkspaceApprun-mode virtual workspace APIs.Checklist
<remarks />and<code />elements on your triple slash comments?