harbur / captain

Captain - Convert your Git workflow to Docker :whale: containers
MIT License
766 stars 51 forks source link

Ability to disable latest tag? #59

Open jmmills opened 8 years ago

jmmills commented 8 years ago

If I build push from a develop branch, my latest tag will map to that build, but when I build from my master branch (stable) my latest tag will map to that build.

This could cause confusion when you are working with something like gitflow, where latest would jump between develop and master depending on whichever branch your CI server built and pushed last.

Possible solutions would be a disable latest tag cli argument, which could in turn be set as part of a build running on a CI server, or a YAML element that mapped latest to a specific branch.

Example of problem:

charlie:foo (master)$ cat Dockerfile
FROM alpine:latest
ENTRYPOINT ["/bin/echo"]
CMD ["Hello, World"]
charlie:foo (master)$ captain build
[CAPTAIN] Skipping build of foo:c69a2b5 - image is already built
[CAPTAIN] Tagging image foo:c69a2b5 as foo:latest
[CAPTAIN] Tagging image foo:c69a2b5 as foo:master
charlie:foo (master)$ docker run --rm foo
Hello, World
charlie:foo (master)$ git checkout develop
Switched to branch 'develop'
charlie:foo (develop)$ cat Dockerfile
FROM alpine:latest
ENTRYPOINT ["/bin/echo"]
CMD ["Bye Bye, Cruel World"]
charlie:foo (develop)$ captain build
[CAPTAIN] Building image foo:latest
Step 1 : FROM alpine:latest
 ---> 4e38e38c8ce0
Step 2 : ENTRYPOINT /bin/echo
 ---> Using cache
 ---> c7525f863b54
Step 3 : CMD Bye Bye, Cruel World
 ---> Using cache
 ---> 4f246db51200
Successfully built 4f246db51200
[CAPTAIN] Tagging image foo:latest as foo:79e6028
[CAPTAIN] Tagging image foo:latest as foo:develop
charlie:foo (develop)$ docker run --rm foo
Bye Bye, Cruel World
charlie:foo (develop)$