Skip to content

Commit 7dfc8a2

Browse files
committed
(build) improve docker manifest publishing
1 parent ce5b851 commit 7dfc8a2

File tree

2 files changed

+6
-16
lines changed

2 files changed

+6
-16
lines changed

build/common/Utilities/DockerContextExtensions.cs

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,16 @@ public static void DockerCreateManifest(this BuildContextBase context, DockerIma
6666
var manifestTags = context.GetDockerTags(dockerImage);
6767
foreach (var tag in manifestTags)
6868
{
69+
var manifestCreateSettings = new DockerManifestCreateSettings { Amend = true };
6970
var amd64Tag = $"{tag}-{Architecture.Amd64.ToSuffix()}";
7071
if (skipArm64Image)
7172
{
72-
context.DockerManifestCreate(tag, amd64Tag);
73+
context.DockerManifestCreate(manifestCreateSettings, tag, amd64Tag);
7374
}
7475
else
7576
{
7677
var arm64Tag = $"{tag}-{Architecture.Arm64.ToSuffix()}";
77-
context.DockerManifestCreate(tag, amd64Tag, arm64Tag);
78+
context.DockerManifestCreate(manifestCreateSettings, tag, amd64Tag, arm64Tag);
7879
}
7980
}
8081
}
@@ -84,19 +85,9 @@ public static void DockerPushManifest(this BuildContextBase context, DockerImage
8485
var manifestTags = context.GetDockerTags(dockerImage);
8586
foreach (var tag in manifestTags)
8687
{
87-
context.DockerManifestPush(tag);
88+
context.DockerManifestPush(new DockerManifestPushSettings { Purge = true }, tag);
8889
}
8990
}
90-
public static void DockerRemoveManifest(this BuildContextBase context, DockerImage dockerImage)
91-
{
92-
var manifestTags = context.GetDockerTags(dockerImage);
93-
foreach (var tag in manifestTags)
94-
{
95-
context.DockerManifestRemove(tag);
96-
}
97-
}
98-
99-
private static void DockerManifestRemove(this ICakeContext context, string tag) => context.DockerCustomCommand($"manifest rm {tag}");
10091

10192
public static void DockerPullImage(this ICakeContext context, DockerImage dockerImage)
10293
{
@@ -190,10 +181,10 @@ private static IEnumerable<string> GetDockerTags(this BuildContextBase context,
190181
}
191182
}
192183

193-
if (!arch.HasValue) return tags;
184+
if (!arch.HasValue) return tags.Distinct();
194185

195186
var suffix = arch.Value.ToSuffix();
196-
return tags.Select(x => $"{x}-{suffix}");
187+
return tags.Select(x => $"{x}-{suffix}").Distinct();
197188

198189
}
199190
private static string DockerImageName(this DockerImage image) => $"{image.Registry}/{(image.UseBaseImage ? Constants.DockerBaseImageName : Constants.DockerImageName)}";

build/docker/Tasks/DockerManifest.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ public override void Run(BuildContext context)
4848
var arm64DockerImage = group.First(x => x.Architecture == Architecture.Arm64);
4949
context.DockerCreateManifest(amd64DockerImage, context.SkipArm64Image(arm64DockerImage));
5050
context.DockerPushManifest(amd64DockerImage);
51-
context.DockerRemoveManifest(amd64DockerImage);
5251
}
5352
}
5453
}

0 commit comments

Comments
 (0)