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:
- Hoisted dependencies —
node_modules are hoisted to the repo root by the workspace manager, so the app subfolder alone is missing most dependencies
- Cross-directory imports — Apps commonly import from sibling packages (e.g.,
../packages/, ../scripts/) which aren't included
- 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
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:node_modulesare hoisted to the repo root by the workspace manager, so the app subfolder alone is missing most dependencies../packages/,../scripts/) which aren't included.envfiles, rootpackage.json,yarn.locketc. are not copiedThis results in build failures like
cross-env: not found(exit code 127) orCould not resolve '../scripts/...'during the Docker build.Expected behavior
Aspire should detect workspace configurations (
workspacesfield in rootpackage.json, orpnpm-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
publishAsDockerFileWithConfigureto 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