Skip to content

Commit

Permalink
feat: build alias for snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
mdelapenya committed Oct 19, 2020
1 parent 3cd405d commit 707e0d7
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion dev-tools/mage/dockerbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 707e0d7

Please sign in to comment.