Node app build output files
- Dominant language
- C#
- Stars
- 6.3k
- Forks
- 991
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 196
Description
### Is there an existing issue for this?
- [x] I have searched the existing issues
### Is your feature request related to a problem? Please describe the problem.
If we have a Node app with build script that output to a specific folder (e.g. `dist`, `.output` ...):
```csharp
var webClient = builder.AddNodeApp("webclient", "../WebClient", ".output/server/index.mjs")
.WithRunScript("dev")
.WithBuildScript("build");
```
It will deploy with all source files.
This happens cause the default Dockerfile builder has no info about the build output, so it copies everything to the runtime image:
https://github.com/dotnet/aspire/blob/a7d2ed187629bab3a78026980062547b27ebd07e/src/Aspire.Hosting.JavaScript/JavaScriptHostingExtensions.cs#L230
which result in a large container with source files, `node_modules` and dev dependencies that are not needed in runtime.
### Describe the solution you'd like
Add new build output annotation that can be used by the default Dockerfile builder to determine which files need to be copied to the runtime image.
```csharp
var webClient = builder.AddNodeApp("webclient", "../WebClient", ".output/server/index.mjs")
.WithRunScript("dev")
.WithBuildScript("build", outputFiles: [".output"]);
```
The alternative solution is for the user to use a custom Dockerfile in the Node app folder.
### Additional context
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.