Skip to content

Instantly share code, notes, and snippets.

@thbkrkr
Created April 1, 2015 14:16
Show Gist options
  • Save thbkrkr/fa1bee34a2f0e93b828e to your computer and use it in GitHub Desktop.
Save thbkrkr/fa1bee34a2f0e93b828e to your computer and use it in GitHub Desktop.
Build, tag and push Docker image
ORG = krkr
NAME = blurb
SHA1 = $(shell git log -1 --pretty=oneline | cut -c-10)
BRANCH = $(shell git branch -a --contains $(SHA1) | egrep '(remotes/|\*)' | egrep -v "(HEAD|detached)" | head -1 | sed -e "s/\* //" -e "s/.*\///")
VERSION = $(BRANCH)-$(SHA1)
REGISTRY = registry.blurb.com
build:
docker build --rm -t $(ORG)/$(NAME):${VERSION} .
docker tag -f $(ORG)/$(NAME):${VERSION} $(ORG)/$(NAME):$(BRANCH)-latest
push:
docker tag -f $(ORG)/$(NAME):${VERSION} $(REGISTRY)/$(ORG)/$(NAME):${VERSION}
docker tag -f $(ORG)/$(NAME):${VERSION} $(REGISTRY)/$(ORG)/$(NAME):$(BRANCH)-latest
docker push $(REGISTRY)/$(ORG)/$(NAME)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment