Created
June 2, 2015 15:02
-
-
Save jalvarezsamayoa/c6142a294a65aa5c27df to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I build my image with the latest tag | |
docker build –t myapp:latest . | |
# get the image's id | |
export latest=“$(docker images | grep myapp:latest | head –n 1 | awk ‘{print $3}’)” | |
# now here comes the cool part, generate a tag for the image related to the current state of the repo | |
docker tag $latest “$(git rev-parse –q HEAD)” # sha of the commit | |
docker tag $latest “$(git describe —always —dirty —tags)” # tag | |
docker tag $latest “$(git rev-parse –q —abbrev-ref HEAD)” #branch | |
# now we upload all these to the registry | |
for image in $(docker images | grep myapp | awk ‘{print $1 “:” $2}’ | head –n 4) ; \ | |
do docker push $image ; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment