Skip to content

Conversation

@eerhardt
Copy link
Member

@eerhardt eerhardt commented Nov 5, 2025

Description

This allows an external system, like azd, to provide the image name for the source image to copy the files from instead of always hard coding the image tag inline.

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
  • Does the change make any security assumptions or guarantees?
    • No
  • Does the change require an update in our Aspire docs?
    • No

@github-actions
Copy link
Contributor

github-actions bot commented Nov 5, 2025

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 12716

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 12716"

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors Dockerfile generation to use parameterized base images through ARG statements and multi-stage FROM statements when using PublishWithContainerFiles. Instead of directly referencing source container images (e.g., sourceimage:latest), the generated Dockerfiles now define ARG variables and named stages for source containers, improving build-time flexibility and following Docker multi-stage build best practices.

Key Changes:

  • Added global ARG statement support to DockerfileBuilder to parameterize base images before FROM statements
  • Created new ContainerFilesExtensions helper class to centralize Dockerfile container files logic
  • Refactored Python, JavaScript, and YARP extensions to use the new centralized container files handling
  • Updated test snapshots to reflect the new Dockerfile format with ARG and stage-based references

Reviewed Changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/Aspire.Hosting/ApplicationModel/Docker/DockerfileBuilder.cs Added support for global ARG statements and logic to write them before stages
src/Aspire.Hosting/ApplicationModel/Docker/ContainerFilesExtensions.cs New file centralizing container files handling with ARG/stage-based approach
src/Aspire.Hosting/ApplicationModel/ProjectResource.cs Updated to call new centralized container files methods
src/Aspire.Hosting.Yarp/YarpResourceExtensions.cs Refactored to use centralized container files extensions
src/Aspire.Hosting.Python/PythonAppResourceBuilderExtensions.cs Removed local AddContainerFiles method in favor of centralized version
src/Aspire.Hosting.JavaScript/JavaScriptHostingExtensions.cs Updated to use centralized container files extensions
tests/Aspire.Hosting.Tests/ProjectResourceTests.cs Enhanced test to verify Dockerfile content through callback
tests/Aspire.Hosting.Tests/Publishing/FakeContainerRuntime.cs Added callback support for BuildImageAsync
tests/Aspire.Hosting.JavaScript.Tests/AddNodeAppTests.cs Added new test for Node.js app with container files
Multiple snapshot files Updated to reflect new ARG-based Dockerfile format

…ContainerFiles

This allows an external system to provide the image name for the source image to copy the files from instead of always hard coding the image tag inline.
@eerhardt eerhardt merged commit 0a28769 into dotnet:main Nov 6, 2025
296 checks passed
@eerhardt eerhardt deleted the ContainerFilesArg branch November 6, 2025 03:07
@eerhardt
Copy link
Member Author

eerhardt commented Nov 6, 2025

/backport to release/13.0

@github-actions
Copy link
Contributor

github-actions bot commented Nov 6, 2025

Started backporting to release/13.0: https://github.com/dotnet/aspire/actions/runs/19123477978

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants