Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/Aspire.Hosting/ApplicationModel/ProjectResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,13 @@ private async Task BuildProjectImage(PipelineStepContext ctx)
// Add COPY --from: statements for each source
stage.AddContainerFiles(this, containerWorkingDir, logger);

// Get the directory service to create temp Dockerfile
var projectDir = Path.GetDirectoryName(projectMetadata.ProjectPath)!;

// Create a unique temporary Dockerfile path for this resource using the directory service.
// Passing a file name causes CreateTempFile to create the file in a new, empty subdirectory,
// which avoids Docker/buildx scanning the entire temporary directory.
var directoryService = ctx.Services.GetRequiredService<IFileSystemService>();
var tempDockerfilePath = directoryService.TempDirectory.CreateTempFile().Path;
var tempDockerfilePath = directoryService.TempDirectory.CreateTempFile("Dockerfile").Path;

var builtSuccessfully = false;
try
Expand Down
6 changes: 4 additions & 2 deletions src/Aspire.Hosting/ContainerResourceBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -718,9 +718,11 @@ public static IResourceBuilder<T> WithDockerfileFactory<T>(this IResourceBuilder
var fullyQualifiedContextPath = Path.GetFullPath(contextPath, builder.ApplicationBuilder.AppHostDirectory)
.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);

// Create a unique temporary Dockerfile path for this resource using the directory service
// Create a unique temporary Dockerfile path for this resource using the directory service.
// Passing a file name causes CreateTempFile to create the file in a new, empty subdirectory,
// which avoids Docker/buildx scanning the entire temporary directory.
var directoryService = builder.ApplicationBuilder.FileSystemService;
var tempDockerfilePath = directoryService.TempDirectory.CreateTempFile().Path;
var tempDockerfilePath = directoryService.TempDirectory.CreateTempFile("Dockerfile").Path;

var imageName = ImageNameGenerator.GenerateImageName(builder);
var imageTag = ImageNameGenerator.GenerateImageTag(builder);
Expand Down
Loading