Skip to content

Commit 54b59a7

Browse files
authored
fix: add --load flag to docker buildx build (#966)
1 parent a2ff878 commit 54b59a7

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"Projects": [
3+
{
4+
"Name": "AWS.Deploy.CLI",
5+
"Type": "Patch",
6+
"ChangelogMessages": [
7+
"Add the --load flag in docker buildx build because, unlike the standard docker build command, buildx doesn't automatically load the resulting image into the local Docker image store. When using buildx with certain docker drivers (like docker-container), the build process happens in a container, and the resulting image needs to be explicitly loaded into the local image store using --load."
8+
]
9+
}
10+
]
11+
}

src/AWS.Deploy.Orchestration/DeploymentBundleHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public async Task BuildContainerImage(CloudApplication cloudApplication, Recomme
6666
if (currentArchitecture != recommendation.DeploymentBundle.EnvironmentArchitecture)
6767
{
6868
var platform = recommendation.DeploymentBundle.EnvironmentArchitecture == SupportedArchitecture.Arm64 ? "linux/arm64" : "linux/amd64";
69-
buildCommand = $"{commandName} buildx build --platform {platform} -t {imageTag} -f \"{dockerFile}\"{buildArgs} .";
69+
buildCommand = $"{commandName} buildx build --load --platform {platform} -t {imageTag} -f \"{dockerFile}\"{buildArgs} .";
7070
}
7171

7272
interactiveService.LogInfoMessage($"Container Execution Directory: {Path.GetFullPath(containerExecutionDirectory)}");

test/AWS.Deploy.CLI.UnitTests/DeploymentBundleHandlerTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public async Task BuildDockerImage_EnvironmentArchitectureNotSet()
9898
}
9999
else
100100
{
101-
Assert.Equal($"docker buildx build --platform linux/amd64 -t {imageTag} -f \"{dockerFilePath}\" .",
101+
Assert.Equal($"docker buildx build --load --platform linux/amd64 -t {imageTag} -f \"{dockerFilePath}\" .",
102102
_commandLineWrapper.CommandsToExecute.First().Command);
103103
}
104104
}
@@ -129,7 +129,7 @@ public async Task BuildDockerImage_EnvironmentArchitectureIsSet(SupportedArchite
129129
else
130130
{
131131
var dockerPlatform = recommendation.DeploymentBundle.EnvironmentArchitecture == SupportedArchitecture.Arm64 ? "linux/arm64" : "linux/amd64";
132-
Assert.Equal($"docker buildx build --platform {dockerPlatform} -t {imageTag} -f \"{dockerFilePath}\" .",
132+
Assert.Equal($"docker buildx build --load --platform {dockerPlatform} -t {imageTag} -f \"{dockerFilePath}\" .",
133133
_commandLineWrapper.CommandsToExecute.First().Command);
134134
}
135135
}
@@ -159,7 +159,7 @@ public async Task BuildDockerImage_DockerExecutionDirectoryNotSet()
159159
}
160160
else
161161
{
162-
Assert.Equal($"docker buildx build --platform linux/amd64 -t {imageTag} -f \"{expectedDockerFile}\" .",
162+
Assert.Equal($"docker buildx build --load --platform linux/amd64 -t {imageTag} -f \"{expectedDockerFile}\" .",
163163
_commandLineWrapper.CommandsToExecute.First().Command);
164164
}
165165
Assert.Equal(dockerExecutionDirectory.FullName,
@@ -192,7 +192,7 @@ public async Task BuildDockerImage_DockerExecutionDirectorySet()
192192
}
193193
else
194194
{
195-
Assert.Equal($"docker buildx build --platform linux/amd64 -t {imageTag} -f \"{expectedDockerFile}\" .",
195+
Assert.Equal($"docker buildx build --load --platform linux/amd64 -t {imageTag} -f \"{expectedDockerFile}\" .",
196196
_commandLineWrapper.CommandsToExecute.First().Command);
197197
}
198198
Assert.Equal(projectPath,
@@ -228,7 +228,7 @@ public async Task BuildDockerImage_AlternativeDockerfilePathSet()
228228
}
229229
else
230230
{
231-
Assert.Equal($"docker buildx build --platform linux/amd64 -t {imageTag} -f \"{dockerfilePath}\" .",
231+
Assert.Equal($"docker buildx build --load --platform linux/amd64 -t {imageTag} -f \"{dockerfilePath}\" .",
232232
_commandLineWrapper.CommandsToExecute.First().Command);
233233
}
234234
Assert.Equal(expectedDockerExecutionDirectory.FullName,

0 commit comments

Comments
 (0)