builder,provision: adding the latest tag to deploy image#1973
Conversation
| for i, tag := range tags { | ||
| opts := docker.CommitContainerOptions{Container: c.ID, Repository: repository, Tag: tag} | ||
| done := limiter.Start(c.HostAddr) | ||
| image, err := client.CommitContainer(opts) |
There was a problem hiding this comment.
Calling client.CommitContainer for each tag is not necessary and it may cause a performance hit, it should be called only once (for the original tag), after the Commit is done we should call client.TagImage to tag the latest tag. This will also allow us to move the commit logic and the image size logic to outside the for loop (removing the ugly if i == 0 block).
Only the PushImage logic should be inside this for loop.
| } | ||
| params.cmds = cmds | ||
| destinationImageWithoutTag := params.destinationImage | ||
| parts := strings.Split(params.destinationImage, ":") |
There was a problem hiding this comment.
You should use the more robust image.SplitImageName (in the app/image pkg) function to split the image as it already handle some corner cases.
| echo " ---> Sending image to repository (${sz})" | ||
| docker push "${img}" | ||
| `, params.destinationImage, baseName, buildIntercontainerStatus, buildIntercontainerDone), | ||
| strings.Join( |
There was a problem hiding this comment.
Nitpick, moving this line and the line below it to the line above should allow us to preserve the old indentation level shortening the diff for this PR. Something like:
"sh", "-ec", strings.Join(append([]string{fmt.Sprintf(`
...
`, ...
cezarsa
left a comment
There was a problem hiding this comment.
I've just noticed that this PR is missing changes to the swarm provisioner. It'll be similar to the docker provisioner but somewhere around
tsuru/provision/swarm/docker.go
Lines 178 to 195 in 82b0563
| attached := s.attachRegister(c, s.clusterSrv, true, a) | ||
| tags := []string{} | ||
| s.clusterSrv.CustomHandler("/images/.*/push", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
| c.Assert(r.URL.Path, check.Equals, "/images/"+fmt.Sprintf("registry.tsuru.io/tsuru/app-myapp")+"/push") |
There was a problem hiding this comment.
No need for Sprintf() and concat here, just make it a single string.
There was a problem hiding this comment.
true. fixed that
This PR is related to #1945. Now, whenever you deploy a new version of your app, you can pull the last image using the tag
latest.