Describe the bug
AddDockerfile (and related overloads) attaches a ContainerBuildOptionsCallbackAnnotation that defaults TargetPlatform to ContainerTargetPlatform.LinuxAmd64. The publishing path (DockerContainerRuntime.RunDockerBuildAsync / PodmanContainerRuntime) reads this annotation and passes --platform linux/amd64 to the runtime build command.
The local dev path, however, goes through DCP via ContainerCreator.ApplyBuildArgumentsAsync, which never reads the annotation. As a result, docker build is invoked without --platform and defaults to the host architecture.
Expected Behavior
The DCP build path should pass the resource's resolved TargetPlatform to the runtime, matching the publishing path's behavior.
Steps To Reproduce
- On an arm64 host (e.g. Apple Silicon), create an AppHost with
builder.AddDockerfile("myapp", "context-path", "Dockerfile").
- Have the Dockerfile install or copy x86_64-only binaries (anything that fails to run under
linux/arm64).
dotnet run the AppHost.
- The build runs as
linux/arm64 and fails, even though the resource's resolved TargetPlatform is LinuxAmd64.
Actual
No --platform flag is sent. The DCP BuildContext model has no Platform field, even though the DCP runtime already supports a json:"platform" field on the build spec.
Anything else?
- Aspire
main (reproduced against 13.4.0-dev build of the repo)
- macOS, arm64
- Docker Desktop
Happy to send a PR — the change is small (add Platform to BuildContext, populate it from ProcessContainerBuildOptionsCallbackAsync in ApplyBuildArgumentsAsync).
Describe the bug
AddDockerfile(and related overloads) attaches aContainerBuildOptionsCallbackAnnotationthat defaultsTargetPlatformtoContainerTargetPlatform.LinuxAmd64. The publishing path (DockerContainerRuntime.RunDockerBuildAsync/PodmanContainerRuntime) reads this annotation and passes--platform linux/amd64to the runtime build command.The local dev path, however, goes through DCP via
ContainerCreator.ApplyBuildArgumentsAsync, which never reads the annotation. As a result,docker buildis invoked without--platformand defaults to the host architecture.Expected Behavior
The DCP build path should pass the resource's resolved
TargetPlatformto the runtime, matching the publishing path's behavior.Steps To Reproduce
builder.AddDockerfile("myapp", "context-path", "Dockerfile").linux/arm64).dotnet runthe AppHost.linux/arm64and fails, even though the resource's resolvedTargetPlatformisLinuxAmd64.Actual
No
--platformflag is sent. The DCPBuildContextmodel has noPlatformfield, even though the DCP runtime already supports ajson:"platform"field on the build spec.Anything else?
main(reproduced against13.4.0-devbuild of the repo)Happy to send a PR — the change is small (add
PlatformtoBuildContext, populate it fromProcessContainerBuildOptionsCallbackAsyncinApplyBuildArgumentsAsync).