Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create image tags at build time #174

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 7 additions & 16 deletions docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,8 @@ func (p Plugin) Exec() error {

cmds = append(cmds, commandBuild(p.Build)) // docker build

for _, tag := range p.Build.Tags {
cmds = append(cmds, commandTag(p.Build, tag)) // docker tag

if p.Dryrun == false {
if p.Dryrun == false {
for _, tag := range p.Build.Tags {
cmds = append(cmds, commandPush(p.Build, tag)) // docker push
}
}
Expand Down Expand Up @@ -205,10 +203,14 @@ func commandBuild(build Build) *exec.Cmd {
"build",
"--rm=true",
"-f", build.Dockerfile,
"-t", build.Name,
}

for _, tag := range build.Tags {
args = append(args, "-t", tag)
}

args = append(args, build.Context)

if build.Squash {
args = append(args, "--squash")
}
Expand Down Expand Up @@ -301,17 +303,6 @@ func hasProxyBuildArg(build *Build, key string) bool {
return false
}

// helper function to create the docker tag command.
func commandTag(build Build, tag string) *exec.Cmd {
var (
source = build.Name
target = fmt.Sprintf("%s:%s", build.Repo, tag)
)
return exec.Command(
dockerExe, "tag", source, target,
)
}

// helper function to create the docker push command.
func commandPush(build Build, tag string) *exec.Cmd {
target := fmt.Sprintf("%s:%s", build.Repo, tag)
Expand Down