-
Notifications
You must be signed in to change notification settings - Fork 715
Add deploy support for Docker Compose #12548
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 12548Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 12548" |
777d882 to
6c85567
Compare
There was a problem hiding this 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 Docker Compose publishing to introduce a multi-step pipeline architecture with separate prepare and publish phases, and enhances container image building to support multiple target platforms via the new Flags enum pattern on ContainerTargetPlatform.
Key changes:
- Separated Docker Compose publishing into distinct pipeline steps (prepare, publish, docker-compose-up, docker-compose-down) for better orchestration
- Changed
ContainerTargetPlatformenum to use[Flags]attribute with explicit values, enabling multi-platform builds via the newAllLinuxcombined value - Refactored
.envfile generation to save without values during publish step, with values populated in separate prepare step - Removed
BuildContainerImagesproperty fromDockerComposeEnvironmentResourceas image building is now handled via pipeline steps
Reviewed Changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Aspire.Hosting/Publishing/ResourceContainerImageBuilder.cs | Added [Flags] to ContainerTargetPlatform enum with explicit values, added AllLinux combined value, refactored extension methods to support multiple platforms, changed MSBuild parameter from ContainerRuntimeIdentifier to RuntimeIdentifiers |
| src/Aspire.Hosting/ContainerResourceBuilderExtensions.cs | Changed default platform from LinuxAmd64 to AllLinux for multi-platform support |
| src/Aspire.Hosting/ApplicationModel/ProjectResource.cs | Changed default platform from LinuxAmd64 to AllLinux for project containers |
| src/Aspire.Hosting/CompatibilitySuppressions.xml | Added compatibility suppressions for enum value changes on all ContainerTargetPlatform fields |
| src/Aspire.Hosting.Docker/EnvFile.cs | Refactored to use SortedDictionary with EnvEntry records for better structure, added Save(path, includeValues) overload to support saving keys without values |
| src/Aspire.Hosting.Docker/DockerComposePublishingContext.cs | Modified to save .env file without values during publish step, storing shared EnvFile instance for later population |
| src/Aspire.Hosting.Docker/DockerComposeEnvironmentResource.cs | Added pipeline steps for prepare, docker-compose-up, and docker-compose-down; added PrepareAsync to populate env file values; removed BuildContainerImages property |
| src/Aspire.Hosting.Docker/Aspire.Hosting.Docker.csproj | Added linked files for process execution utilities to support docker-compose command execution |
| tests/Aspire.Hosting.Docker.Tests/DockerComposePublisherTests.cs | Updated test for image building behavior, added tests for prepare step with different environment names, added TestHostEnvironment helper class |
| tests/Aspire.Hosting.Docker.Tests/Snapshots/*.env | Updated snapshot files to reflect env files with empty values (keys only) during publish phase |
tests/Aspire.Hosting.Docker.Tests/DockerComposePublisherTests.cs
Outdated
Show resolved
Hide resolved
|
@copilot Address the feedback from Copilot. |
|
@captainsafia I've opened a new pull request, #12575, to work on those changes. Once the pull request is ready, I'll request review from you. |
|
@captainsafia I've opened a new pull request, #12580, to work on those changes. Once the pull request is ready, I'll request review from you. |
* Initial plan * Address Copilot feedback: Remove duplicate registration and simplify EnvFile logic Co-authored-by: captainsafia <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: captainsafia <[email protected]>
… status messages (#12580) * Initial plan * Address PR feedback: Update env file naming, reduce log verbosity, and enhance success message Co-authored-by: captainsafia <[email protected]> * Fix log verbosity: Move completion message to Debug level instead of task creation Co-authored-by: captainsafia <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: captainsafia <[email protected]>
cf4bb7e to
85b9ca1
Compare
|
/backport to release/13.0 |
|
Started backporting to release/13.0: https://github.com/dotnet/aspire/actions/runs/18989559753 |
|
@captainsafia backporting to "release/13.0" failed, the patch most likely resulted in conflicts: $ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch
Applying: Add deploy support for Docker Compose
.git/rebase-apply/patch:1058: new blank line at EOF.
+
.git/rebase-apply/patch:1073: new blank line at EOF.
+
.git/rebase-apply/patch:1091: new blank line at EOF.
+
warning: 3 lines add whitespace errors.
Using index info to reconstruct a base tree...
M src/Aspire.Hosting.Docker/DockerComposePublishingContext.cs
M src/Aspire.Hosting.Docker/EnvFile.cs
M src/Aspire.Hosting/CompatibilitySuppressions.xml
Falling back to patching base and 3-way merge...
Auto-merging src/Aspire.Hosting.Docker/DockerComposePublishingContext.cs
Auto-merging src/Aspire.Hosting.Docker/EnvFile.cs
CONFLICT (content): Merge conflict in src/Aspire.Hosting.Docker/EnvFile.cs
Auto-merging src/Aspire.Hosting/CompatibilitySuppressions.xml
CONFLICT (content): Merge conflict in src/Aspire.Hosting/CompatibilitySuppressions.xml
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0001 Add deploy support for Docker Compose
Error: The process '/usr/bin/git' failed with exit code 128Please backport manually! |

This pull request introduces significant improvements to the Docker Compose environment resource handling and environment variable file management in the Aspire Hosting Docker integration. The changes streamline the pipeline steps for Docker Compose operations, refactor the
.envfile logic for better maintainability and clarity, and remove some legacy build logic. The most important updates are grouped below:Pipeline Step Management and Docker Compose Operations:
DockerComposeEnvironmentResourceto define asynchronous pipeline steps for publishing, preparing, deploying (docker-compose up), and shutting down (docker-compose down). These steps are now dynamically created and properly wired up for resource dependencies.DockerComposeUpAsync,DockerComposeDownAsync, andPrepareAsync, including improved environment variable handling and process execution with logging and error reporting.Environment Variable File Handling:
EnvFileclass to use a sorted dictionary of strongly-typed entries, preserving comments and supporting both value-included and key-only.envfile writing. This improves the clarity and maintainability of environment variable management. [1] [2] [3]EnvFilestructure, ensuring comments are preserved and values are handled consistently.Build Logic and Resource Configuration:
BuildContainerImagesproperty and associated logic fromDockerComposeEnvironmentResourceand the publishing context, simplifying image build management and delegating build step dependencies to the pipeline configuration. [1] [2] [3]ProjectResourceto useAllLinuxfor broader compatibility.Project Structure and Code Organization:
ProcessResult.cs,ProcessSpec.cs,ProcessUtil.cs) to the project for improved process management and code reuse.Dependency Injection and Logging:
These changes collectively enhance the reliability, maintainability, and clarity of the Docker Compose integration and environment management in Aspire Hosting Docker.