-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
165 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
namespace Build; | ||
using DockerBuildXImageToolsCreateSettings = Build.Cake.Docker.DockerBuildXImageToolsCreateSettings; | ||
|
||
public abstract class BaseDockerBuildManifest : FrostingTask<BuildContext> | ||
{ | ||
protected const string Prefix = "org.opencontainers.image"; | ||
|
||
private static readonly string[] Annotations = | ||
[ | ||
$"{Prefix}.authors=GitTools Maintainers", | ||
$"{Prefix}.vendor=GitTools", | ||
$"{Prefix}.licenses=MIT", | ||
$"{Prefix}.source=https://github.com/GitTools/build-images.git", | ||
$"{Prefix}.created={DateTime.UtcNow:O}", | ||
]; | ||
|
||
protected void DockerManifest(BuildContext context, DockerDepsImage dockerImage) | ||
{ | ||
var manifestTags = dockerImage.GetDockerTags(context.DockerRegistry); | ||
foreach (var tag in manifestTags) | ||
{ | ||
var amd64Tag = $"{tag}-{Architecture.Amd64.ToSuffix()}"; | ||
var arm64Tag = $"{tag}-{Architecture.Arm64.ToSuffix()}"; | ||
|
||
var settings = GetManifestSettings(dockerImage, tag); | ||
context.DockerBuildXImageToolsCreate(settings, [amd64Tag, arm64Tag]); | ||
} | ||
} | ||
|
||
protected virtual DockerBuildXImageToolsCreateSettings GetManifestSettings(DockerDepsImage dockerImage, string tag) | ||
{ | ||
var settings = new DockerBuildXImageToolsCreateSettings | ||
{ | ||
Tag = [tag], | ||
Annotation = | ||
[ | ||
.. Annotations.Select(a => "index:" + a).ToArray(), | ||
] | ||
}; | ||
return settings; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
namespace Build; | ||
using DockerBuildXImageToolsCreateSettings = Build.Cake.Docker.DockerBuildXImageToolsCreateSettings; | ||
|
||
public class DockerBuildDepsManifest : BaseDockerBuildManifest | ||
{ | ||
public override void Run(BuildContext context) | ||
{ | ||
if (!context.PushImages) | ||
return; | ||
|
||
// build/push manifests | ||
foreach (var group in context.DepsImages.GroupBy(x => new { x.Distro })) | ||
{ | ||
var dockerImage = group.First(); | ||
DockerManifest(context, dockerImage); | ||
} | ||
} | ||
|
||
protected override DockerBuildXImageToolsCreateSettings GetManifestSettings(DockerDepsImage dockerImage, string tag) | ||
{ | ||
var settings = base.GetManifestSettings(dockerImage, tag); | ||
settings.Annotation = | ||
[ | ||
.. settings.Annotation, | ||
$"index:{Prefix}.description=GitTools deps images ({dockerImage.Distro})" | ||
]; | ||
return settings; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
namespace Build; | ||
using DockerBuildXImageToolsCreateSettings = Build.Cake.Docker.DockerBuildXImageToolsCreateSettings; | ||
|
||
public class DockerBuildImagesManifest : BaseDockerBuildManifest | ||
{ | ||
public override void Run(BuildContext context) | ||
{ | ||
if (!context.PushImages) | ||
return; | ||
|
||
// build/push manifests | ||
foreach (var group in context.Images.GroupBy(x => new { x.Distro, x.Variant, x.Version })) | ||
{ | ||
var dockerImage = group.First(); | ||
DockerManifest(context, dockerImage); | ||
} | ||
} | ||
|
||
protected override DockerBuildXImageToolsCreateSettings GetManifestSettings(DockerDepsImage dockerImage, string tag) | ||
{ | ||
var (distro, version, variant, _) = (DockerImage)dockerImage; | ||
var suffix = $"({distro}-{variant}-{version})"; | ||
var settings = base.GetManifestSettings(dockerImage, tag); | ||
settings.Annotation = | ||
[ | ||
.. settings.Annotation, | ||
$"index:{Prefix}.description=GitTools build images {suffix}", | ||
]; | ||
return settings; | ||
} | ||
} |