thbkrkr
4/1/2015 - 2:16 PM

Build, tag and push Docker image

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)