Skip to content

Commit 8547e2c

Browse files
Copilotcaptainsafia
andcommitted
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]>
1 parent 54f0caa commit 8547e2c

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

src/Aspire.Hosting.Docker/DockerComposeEnvironmentResource.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ private async Task DockerComposeUpAsync(PipelineStepContext context)
252252
}
253253
else
254254
{
255-
await deployTask.CompleteAsync($"Docker Compose deployment complete for **{Name}**", CompletionState.Completed, context.CancellationToken).ConfigureAwait(false);
255+
await deployTask.CompleteAsync($"Service **{Name}** is now running with Docker Compose locally", CompletionState.Completed, context.CancellationToken).ConfigureAwait(false);
256256
}
257257
}
258258
}
@@ -364,7 +364,7 @@ private string GetEnvFilePath(PipelineStepContext context)
364364
var outputPath = PublishingContextUtils.GetEnvironmentOutputPath(context, this);
365365
var hostEnvironment = context.Services.GetService<Microsoft.Extensions.Hosting.IHostEnvironment>();
366366
var environmentName = hostEnvironment?.EnvironmentName ?? Name;
367-
var envFilePath = Path.Combine(outputPath, $"{environmentName}.env");
367+
var envFilePath = Path.Combine(outputPath, $".env.{environmentName}");
368368
return envFilePath;
369369
}
370370
}

src/Aspire.Hosting.Docker/DockerComposePublisherLoggerExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ internal static partial class DockerComposePublisherLoggerExtensions
2525
[LoggerMessage(LogLevel.Information, "No resources found in the model.")]
2626
internal static partial void EmptyModel(this ILogger logger);
2727

28-
[LoggerMessage(LogLevel.Information, "Successfully generated Compose output in '{OutputPath}'")]
28+
[LoggerMessage(LogLevel.Debug, "Successfully generated Compose output in '{OutputPath}'")]
2929
internal static partial void FinishGeneratingDockerCompose(this ILogger logger, string outputPath);
3030

3131
[LoggerMessage(LogLevel.Warning, "Failed to get container image for resource '{ResourceName}', it will be skipped in the output.")]

tests/Aspire.Hosting.Docker.Tests/DockerComposePublisherTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ public async Task PrepareStep_GeneratesCorrectEnvFileWithDefaultEnvironmentName(
520520
var app = builder.Build();
521521
app.Run();
522522

523-
var envFileContent = await File.ReadAllTextAsync(Path.Combine(tempDir.Path, "Production.env"));
523+
var envFileContent = await File.ReadAllTextAsync(Path.Combine(tempDir.Path, ".env.Production"));
524524
await Verify(envFileContent, "env")
525525
.UseParameters("default-environment");
526526
}
@@ -549,7 +549,7 @@ public async Task PrepareStep_GeneratesCorrectEnvFileWithCustomEnvironmentName()
549549
app.Run();
550550

551551
// Verify that the env file is created with the custom environment name
552-
var envFilePath = Path.Combine(tempDir.Path, "Staging.env");
552+
var envFilePath = Path.Combine(tempDir.Path, ".env.Staging");
553553
Assert.True(File.Exists(envFilePath), $"Expected env file at {envFilePath}");
554554

555555
var envFileContent = await File.ReadAllTextAsync(envFilePath);
@@ -583,7 +583,7 @@ public async Task PrepareStep_GeneratesEnvFileWithVariousParameterTypes()
583583
var app = builder.Build();
584584
app.Run();
585585

586-
var envFileContent = await File.ReadAllTextAsync(Path.Combine(tempDir.Path, "Production.env"));
586+
var envFileContent = await File.ReadAllTextAsync(Path.Combine(tempDir.Path, ".env.Production"));
587587
await Verify(envFileContent, "env")
588588
.UseParameters("various-parameters");
589589
}

0 commit comments

Comments
 (0)