Skip to content

Commit 1b0aa02

Browse files
Copiloteerhardt
andcommitted
Revert CopyContainerFilesAsync from IContainerRuntime - no longer needed
The new design uses DockerfileBuilder with COPY --from: instead of extracting files from containers to the host filesystem, so the CopyContainerFilesAsync method is no longer needed. Co-authored-by: eerhardt <[email protected]>
1 parent cd9a23f commit 1b0aa02

File tree

2 files changed

+0
-55
lines changed

2 files changed

+0
-55
lines changed

src/Aspire.Hosting/Publishing/ContainerRuntimeBase.cs

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -63,60 +63,6 @@ await ExecuteContainerCommandAsync(
6363
imageName).ConfigureAwait(false);
6464
}
6565

66-
public virtual async Task CopyContainerFilesAsync(string imageName, string sourcePath, string destinationPath, CancellationToken cancellationToken)
67-
{
68-
var containerName = $"temp-{Guid.NewGuid():N}";
69-
70-
try
71-
{
72-
// Create a temporary container from the image
73-
_logger.LogDebug("Creating temporary container {ContainerName} from image {ImageName}", containerName, imageName);
74-
var createArguments = $"create --name {containerName} {imageName}";
75-
76-
var createExitCode = await ExecuteContainerCommandWithExitCodeAsync(
77-
createArguments,
78-
$"{Name} create for {{ContainerName}} from {{ImageName}} failed with exit code {{ExitCode}}.",
79-
$"{Name} create for {{ContainerName}} from {{ImageName}} succeeded.",
80-
cancellationToken,
81-
new object[] { containerName, imageName }).ConfigureAwait(false);
82-
83-
if (createExitCode != 0)
84-
{
85-
throw new DistributedApplicationException($"{Name} create failed with exit code {createExitCode}.");
86-
}
87-
88-
// Copy files from the container
89-
_logger.LogDebug("Copying files from {ContainerName}:{SourcePath} to {DestinationPath}", containerName, sourcePath, destinationPath);
90-
var copyArguments = $"cp {containerName}:{sourcePath} {destinationPath}";
91-
92-
await ExecuteContainerCommandAsync(
93-
copyArguments,
94-
$"{Name} cp from {{ContainerName}}:{{SourcePath}} to {{DestinationPath}} failed with exit code {{ExitCode}}.",
95-
$"{Name} cp from {{ContainerName}}:{{SourcePath}} to {{DestinationPath}} succeeded.",
96-
$"{Name} cp failed with exit code {{0}}.",
97-
cancellationToken,
98-
containerName, sourcePath, destinationPath).ConfigureAwait(false);
99-
}
100-
finally
101-
{
102-
// Clean up the temporary container
103-
_logger.LogDebug("Removing temporary container {ContainerName}", containerName);
104-
var rmArguments = $"rm {containerName}";
105-
106-
var rmExitCode = await ExecuteContainerCommandWithExitCodeAsync(
107-
rmArguments,
108-
$"{Name} rm for {{ContainerName}} failed with exit code {{ExitCode}}.",
109-
$"{Name} rm for {{ContainerName}} succeeded.",
110-
cancellationToken,
111-
new object[] { containerName }).ConfigureAwait(false);
112-
113-
if (rmExitCode != 0)
114-
{
115-
_logger.LogWarning("{RuntimeName} rm for {ContainerName} failed with exit code {ExitCode}.", Name, containerName, rmExitCode);
116-
}
117-
}
118-
}
119-
12066
/// <summary>
12167
/// Executes a container runtime command with standard logging and error handling.
12268
/// </summary>

src/Aspire.Hosting/Publishing/IContainerRuntime.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,4 @@ internal interface IContainerRuntime
1212
Task BuildImageAsync(string contextPath, string dockerfilePath, string imageName, ContainerBuildOptions? options, Dictionary<string, string?> buildArguments, Dictionary<string, string?> buildSecrets, string? stage, CancellationToken cancellationToken);
1313
Task TagImageAsync(string localImageName, string targetImageName, CancellationToken cancellationToken);
1414
Task PushImageAsync(string imageName, CancellationToken cancellationToken);
15-
Task CopyContainerFilesAsync(string imageName, string sourcePath, string destinationPath, CancellationToken cancellationToken);
1615
}

0 commit comments

Comments
 (0)