PublishWithStaticFiles and PublishAsStaticWebsite should allow Dockerfile customization
- 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
## Describe the bug
Neither `YarpResourceExtensions.PublishWithStaticFiles` nor the new `JavaScriptHostingExtensions.PublishAsStaticWebsite` (from #15736) provide any way to customize the generated Dockerfile content.
### YARP `PublishWithStaticFiles`
Introduced in #12483. Internally calls `WithDockerfileBuilder` via the private `EnsurePublishWithStaticFilesDockerFileBuilder()` method, which generates a fixed Dockerfile (FROM yarp → COPY to /app/wwwroot). No configure callback or overload exists to modify this.
### JavaScript `PublishAsStaticWebsite`
Introduced in #15736. Has an `Action` configure callback, but that only controls `OutputPath`, `StripPrefix`, and `TargetEndpointName`. There's no way to customize the actual Dockerfile — it delegates to the YARP layer which has the same limitation.
## Expected Behavior
Both methods should provide a way to customize the generated Dockerfile content — either via:
- A `Func` callback parameter
- An overload that accepts additional Dockerfile stages/instructions
- A configure callback that exposes the `DockerfileBuilder`
This is especially important since `WithDockerfileBuilder` is not available in polyglot AppHosts (see #15858), so TS/Python/Java users have no workaround at all.
## Use Cases
- Adding custom COPY instructions (e.g., additional config files, .env files)
- Adding RUN instructions (e.g., installing extra packages in the container)
- Customizing the base image beyond what `WithDockerfileBaseImage` provides
- Adding multi-stage build steps before the final YARP stage
## Anything else?
Related: #15858 (WithDockerfileBuilder not available in polyglot AppHosts)
Contributor guide
Assessment
This issue has not been assessed yet.