Skip to content

Instantly share code, notes, and snippets.

@seventhskye
Last active May 25, 2016 13:26
Show Gist options
  • Save seventhskye/7d067265addc884f95d21b3b57022c6d to your computer and use it in GitHub Desktop.
Save seventhskye/7d067265addc884f95d21b3b57022c6d to your computer and use it in GitHub Desktop.
A Makefile for docker images.
DATE = $(shell date)
NAME = dcrbsltd/image
VERSION = 1
all: build
build:
docker build -t $(NAME):$(VERSION) --rm .
tag_latest:
docker tag $(NAME):$(VERSION) $(NAME):latest
test:
env NAME=$(NAME) VERSION=$(VERSION) ./test
release: test tag_latest
@if ! docker images $(NAME) | awk '{ print $$2 }' | grep -q -F $(VERSION); then echo "$(NAME) version $(VERSION) is not yet built. Please run 'make build'"; false; fi
@if ! head -n 1 Changelog.md | grep -q 'release date'; then echo 'Please note the release date in Changelog.md.' && false; fi
docker push $(NAME)
@echo "*** Don't forget to create a tag. git tag rel-$(VERSION) && git push origin rel-$(VERSION)"
git_commit:
@echo "Enter commit message:"
@read REPLY; \
echo "${DATE} - $$REPLY" >> CHANGELOG; \
git add --all; \
git commit -m "$$REPLY"; \
git push
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment