Skip to content

Auto-generated Dockerfiles break yarn/npm workspaces monorepos #15877

@DamianEdwards

Description

@DamianEdwards

Description

When using publishAsDockerFile (or the auto-generated Dockerfile for JavaScript apps), Aspire copies only the app's subfolder into the Docker image. This breaks monorepos using yarn workspaces (or npm workspaces) because:

  1. Hoisted dependenciesnode_modules are hoisted to the repo root by the workspace manager, so the app subfolder alone is missing most dependencies
  2. Cross-directory imports — Apps commonly import from sibling packages (e.g., ../packages/, ../scripts/) which aren't included
  3. Root config files.env files, root package.json, yarn.lock etc. are not copied

This results in build failures like cross-env: not found (exit code 127) or Could not resolve '../scripts/...' during the Docker build.

Expected behavior

Aspire should detect workspace configurations (workspaces field in root package.json, or pnpm-workspace.yaml) and use the workspace root as the Docker build context, copying all necessary workspace packages.

Alternatively, provide clear documentation and examples for monorepo setups, or allow the user to easily specify the build context.

Workaround

Use publishAsDockerFileWithConfigure to point at a custom Dockerfile that uses the repo root as build context:

\\ ypescript
app.publishAsDockerFileWithConfigure(async (container) => {
await container.withDockerfile("../", { dockerfilePath: "Dockerfile.aspire" });
});
\\

Environment

  • Aspire SDK: 13.2.1 (TypeScript)
  • Package manager: Yarn 1.x with workspaces

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-polyglotIssues related to polyglot apphostsaspirifridaysBugs found during Aspiri-FridayjavascriptPull requests that update Javascript code

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions