Skip to content

Conversation

@captainsafia
Copy link
Member

@captainsafia captainsafia commented Nov 3, 2025

Customer Impact

Docker Compose environments now participate fully in the Aspire pipeline with explicit steps for publish, prepare, docker-compose-up (required by deploy), and docker-compose-down.

Testing

Manual.

Risk

Mediumm, because:

  • Changes are scoped to the Docker Compose deployment path and primarily restructure work into explicit pipeline steps with clearer ordering and reporting.
  • Env-file behavior is more deterministic and environment-specific.
  • API change: the BuildContainerImages option was removed from DockerComposeEnvironmentResource and image building during publish was deleted in favor of pipeline-driven build steps. Existing flows relying on image auto-build during publish will now rely on the wired build steps prior to deploy. Impact is limited and aligned with pipeline design.

Regression?

No, because the new steps preserve (and make explicit) the same publish capabilities that existed before.

captainsafia and others added 2 commits November 3, 2025 16:44
* Add deploy support for Docker Compose

* Fix duplicate service registration and simplify EnvFile logic (#12575)

* 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]>

* Refine Docker Compose publishing: env file naming, log verbosity, and 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]>

* Fix passing of RIDs in dotnet publish for back-compat

---------

Co-authored-by: Copilot <[email protected]>
Co-authored-by: captainsafia <[email protected]>
* Initial plan

* Update ContainerTargetPlatform from AllLinux to LinuxAmd64

- Replace ContainerTargetPlatform.AllLinux with LinuxAmd64 in ProjectResource.cs (2 occurrences)
- Replace ContainerTargetPlatform.AllLinux with LinuxAmd64 in ContainerResourceBuilderExtensions.cs
- Remove AllLinux enum value from ContainerTargetPlatform enum definition

Co-authored-by: captainsafia <[email protected]>

* Completed: Update ContainerTargetPlatform from AllLinux to LinuxAmd64

Co-authored-by: captainsafia <[email protected]>

* Restore AllLinux enum and revert unintended template changes

- Restore the AllLinux enum value in ContainerTargetPlatform
- Revert all unintended changes to Aspire.ProjectTemplates localization files

Co-authored-by: davidfowl <[email protected]>

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: captainsafia <[email protected]>
Co-authored-by: davidfowl <[email protected]>
@github-actions
Copy link
Contributor

github-actions bot commented Nov 3, 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 -- 12629

Or

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

@captainsafia captainsafia changed the title [release/13.0]Add deploy support for Docker Compose [release/13.0] Add deploy support for Docker Compose Nov 3, 2025
@captainsafia captainsafia marked this pull request as ready for review November 3, 2025 17:09
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 the Docker Compose publishing workflow to support multi-step pipelines with separate prepare, publish, and deploy stages. The key changes enable environment-specific .env files (.env.Production, .env.Staging, etc.) and introduce support for multi-platform container builds using flags on the ContainerTargetPlatform enum.

  • Separates Docker Compose workflow into distinct pipeline steps (publish, prepare, docker-compose-up, docker-compose-down)
  • Changes .env file generation to use environment-specific naming (.env.{EnvironmentName})
  • Adds [Flags] attribute to ContainerTargetPlatform enum to enable multi-platform builds with a new AllLinux combined value
  • Refactors EnvFile class to support both key-only and key-value persistence modes

Reviewed Changes

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

Show a summary per file
File Description
src/Aspire.Hosting/Publishing/ResourceContainerImageBuilder.cs Converts ContainerTargetPlatform enum to flags-based design; updates extension methods to handle multiple platforms; modifies MSBuild property selection based on RID count
src/Aspire.Hosting/CompatibilitySuppressions.xml Adds API compatibility suppressions for enum value changes
src/Aspire.Hosting.Docker/EnvFile.cs Refactors to use sorted dictionary; adds support for preserving comments and saving with/without values
src/Aspire.Hosting.Docker/DockerComposePublishingContext.cs Simplifies publish step to save keys only; removes image building logic
src/Aspire.Hosting.Docker/DockerComposeEnvironmentResource.cs Adds prepare, docker-compose-up, and docker-compose-down pipeline steps; implements environment-specific .env file naming
src/Aspire.Hosting.Docker/DockerComposePublisherLoggerExtensions.cs Changes log level from Information to Debug
src/Aspire.Hosting.Docker/Aspire.Hosting.Docker.csproj Adds process-related shared files
tests/Aspire.Hosting.Docker.Tests/DockerComposePublisherTests.cs Adds tests for environment-specific .env files; updates test for image building behavior
tests/Aspire.Hosting.Docker.Tests/Snapshots/*.verified.env Updates snapshot files to reflect empty values in publish step

{
var outputPath = PublishingContextUtils.GetEnvironmentOutputPath(context, this);
var hostEnvironment = context.Services.GetService<Microsoft.Extensions.Hosting.IHostEnvironment>();
var environmentName = hostEnvironment?.EnvironmentName ?? Name;
Copy link

Copilot AI Nov 3, 2025

Choose a reason for hiding this comment

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

The fallback to Name (the Docker Compose environment resource name) when EnvironmentName is unavailable is problematic. The tests expect .env.Production as the default, not .env.{resource-name}. Based on the test PrepareStep_GeneratesCorrectEnvFileWithDefaultEnvironmentName which expects .env.Production, the fallback should be \"Production\" rather than Name.

Suggested change
var environmentName = hostEnvironment?.EnvironmentName ?? Name;
var environmentName = hostEnvironment?.EnvironmentName ?? "Production";

Copilot uses AI. Check for mistakes.
{
private readonly List<string> _lines = [];
private readonly HashSet<string> _keys = [];
private readonly SortedDictionary<string, EnvEntry> _entries = [];
Copy link

Copilot AI Nov 3, 2025

Choose a reason for hiding this comment

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

Using SortedDictionary adds O(log n) overhead for insertions and lookups compared to a regular Dictionary. If the sorted order is only needed during Save(), consider using a regular Dictionary and sorting during serialization with OrderBy() to improve runtime performance for add/lookup operations.

Copilot uses AI. Check for mistakes.
@joperezr joperezr added the Servicing-approved Approved for servicing release label Nov 3, 2025
@joperezr
Copy link
Member

joperezr commented Nov 3, 2025

Part of the aspire pipelines experience, localized to compose. Approved.

@captainsafia captainsafia enabled auto-merge (squash) November 3, 2025 23:12
@@ -1,5 +1,5 @@
# Parameter param1
PARAM1=changed
PARAM1=
Copy link
Member

Choose a reason for hiding this comment

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

Are these changes intentional?

internal static partial void EmptyModel(this ILogger logger);

[LoggerMessage(LogLevel.Information, "Successfully generated Compose output in '{OutputPath}'")]
[LoggerMessage(LogLevel.Debug, "Successfully generated Compose output in '{OutputPath}'")]
Copy link
Member

Choose a reason for hiding this comment

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

Without this, will people know where to look for the output?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, there was some duplication here because we emit the output in the completion message for the ReportingStep. I stepped down to debug since we surface Info logs by default now.

Comment on lines +163 to +164
buildSteps.RequiredBy(WellKnownPipelineSteps.Deploy)
.RequiredBy($"docker-compose-up-{Name}")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
buildSteps.RequiredBy(WellKnownPipelineSteps.Deploy)
.RequiredBy($"docker-compose-up-{Name}")
buildSteps.RequiredBy($"docker-compose-up-{Name}")

Don't we only need this? Since dockerComposeUpStep.RequiredBy(WellKnownPipelineSteps.Deploy);.

@captainsafia captainsafia merged commit d7c175b into release/13.0 Nov 3, 2025
588 of 592 checks passed
@captainsafia captainsafia deleted the safia/bp-docker-compose branch November 3, 2025 23:25
@Falco20019
Copy link

The removal of BuildContainerImages is not mentioned at https://learn.microsoft.com/en-us/dotnet/aspire/compatibility/13.0/

I had to manually search for this ticket to find the change on why my code was breaking. Please update the documentation.

@davidfowl
Copy link
Member

Future breaking changes will be on aspire.dev https://aspire.dev/whats-new/aspire-13/#%EF%B8%8F-breaking-changes

@Falco20019
Copy link

Falco20019 commented Nov 20, 2025

@davidfowl It's also not mentioned there, did check that one as-well.

@davidfowl
Copy link
Member

We suck 😄.

There's a new step for docker compose that you can use:

aspire do prepare-{name of resource}

This will prompt for parameters, build images and create a final env file with values without running compose up

@Falco20019
Copy link

@davidfowl Thanks for the heads-up. Sadly the ENV file is very broken due to wrong ordering. I created #13067 as follow-up.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Servicing-approved Approved for servicing release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants