From 707e0d71556553b15388adec0c7118ff89210ac9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20de=20la=20Pe=C3=B1a?= Date: Mon, 19 Oct 2020 13:19:22 +0200 Subject: [PATCH] feat: build alias for snapshots --- dev-tools/mage/dockerbuilder.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/dev-tools/mage/dockerbuilder.go b/dev-tools/mage/dockerbuilder.go index 90a994348846..4439f9cc75ed 100644 --- a/dev-tools/mage/dockerbuilder.go +++ b/dev-tools/mage/dockerbuilder.go @@ -182,13 +182,26 @@ func (b *dockerBuilder) expandDockerfile(templatesDir string, data map[string]in func (b *dockerBuilder) dockerBuild() (string, error) { tag := fmt.Sprintf("%s:%s", b.imageName, b.Version) + aliasTag := "" if b.Snapshot { tag = tag + "-SNAPSHOT" + // remove third number in version + aliasTag = fmt.Sprintf("%s:%s-SNAPSHOT", b.imageName, b.Version[0:strings.LastIndex(b.Version, ".")]) } if repository, _ := b.ExtraVars["repository"]; repository != "" { tag = fmt.Sprintf("%s/%s", repository, tag) + aliasTag = fmt.Sprintf("%s/%s", repository, aliasTag) } - return tag, sh.Run("docker", "build", "-t", tag, b.buildDir) + + args := []string{ + "build", "-t", tag, + } + if aliasTag != "" { + args = append(args, "-t", aliasTag) + } + args = append(args, b.buildDir) + + return tag, sh.Run("docker", args...) } func (b *dockerBuilder) dockerSave(tag string) error {