Example #1
0
    public static void DockerPushImage(this BuildContextBase context, DockerImage dockerImage)
    {
        var tags = context.GetDockerTags(dockerImage, dockerImage.Architecture);

        foreach (var tag in tags)
        {
            context.DockerPush(tag);
        }
    }
Example #2
0
    public static void DockerPushManifest(this BuildContextBase context, DockerImage dockerImage)
    {
        var manifestTags = context.GetDockerTags(dockerImage);

        foreach (var tag in manifestTags)
        {
            context.DockerManifestPush(tag);
        }
    }
Example #3
0
    public static void DockerTestImage(this BuildContextBase context, DockerImage dockerImage)
    {
        var tags = context.GetDockerTags(dockerImage, dockerImage.Architecture);

        foreach (var tag in tags)
        {
            context.DockerTestRun(tag, dockerImage.Architecture, "/repo", "/showvariable", "FullSemver");
        }
    }
Example #4
0
    public static void DockerCreateManifest(this BuildContextBase context, DockerImage dockerImage, bool skipArm64Image)
    {
        var manifestTags = context.GetDockerTags(dockerImage);

        foreach (var tag in manifestTags)
        {
            var amd64Tag = $"{tag}-{Architecture.Amd64.ToSuffix()}";
            if (skipArm64Image)
            {
                context.DockerManifestCreate(tag, amd64Tag);
            }
            else
            {
                var arm64Tag = $"{tag}-{Architecture.Arm64.ToSuffix()}";
                context.DockerManifestCreate(tag, amd64Tag, arm64Tag);
            }
        }
    }
Example #5
0
    public static void DockerBuildImage(this BuildContextBase context, DockerImage dockerImage)
    {
        if (context.Version == null)
        {
            return;
        }

        var(distro, targetFramework, arch, registry, _) = dockerImage;

        context.Information($"Building image: {dockerImage}");

        var workDir = Paths.Src.Combine("Docker");
        var tags    = context.GetDockerTags(dockerImage, arch);

        var suffix    = arch.ToSuffix();
        var platforms = new List <string> {
            $"linux/{suffix}"
        };

        var buildSettings = new DockerImageBuildSettings
        {
            Rm       = true,
            Tag      = tags.ToArray(),
            File     = workDir.CombineWithFilePath("Dockerfile").FullPath,
            BuildArg = new[]
            {
                $"contentFolder=/content",
                $"REGISTRY={registry}",
                $"DOTNET_VERSION={targetFramework}",
                $"DISTRO={distro}",
                $"VERSION={context.Version.NugetVersion}"
            },
            Pull     = true,
            Platform = string.Join(",", platforms),
        };

        context.DockerBuild(buildSettings, workDir.ToString(), "--output type=docker");
    }