Skip to content

Instantly share code, notes, and snippets.

@dan-compton dan-compton/Makefile
Last active Apr 11, 2016

Embed
What would you like to do?
Ultimate docker makefile work in progress forever
# CONTAINER_TAG is git revision unless overriden by YOURPROJ_VERSION
CONTAINER_TAG := $(shell git rev-parse HEAD)
ifeq ($(YOURPROJ_VERSION), "")
CONTAINER_TAG := $(YOURPROJ_VERSION)
endif
CONTAINER_NAME := "docker/yourproj"
CONTAINER_PORTS := "7000:7000"
all: clean deps build
clean:
$(MAKE) -i docker-clean
deps:
docker-compose stop
docker-compose rm -f
docker-compose up -d
docker run --link some_dependency aanand/wait
build:
docker build --build-arg CONTAINER_TAG=${CONTAINER_TAG} -t ${CONTAINER_NAME}:${CONTAINER_TAG} .
run:
docker run -l "${CONTAINER_NAME}:${CONTAINER_TAG}" -p ${CONTAINER_PORTS} ${CONTAINER_NAME}:${CONTAINER_TAG}
stop:
docker stop `docker ps --filter label="${CONTAINER_NAME}:${CONTAINER_TAG}" --format "{{.ID}}"`
docker-clean:
docker rmi -f ${CONTAINER_NAME}:${CONTAINER_TAG}
docker-push:
docker push ${CONTAINER_NAME}:${CONTAINER_TAG}
.PHONY: clean all
## ADD TO DOCKERFILE
#ARG CONTAINER_TAG
#ENV CONTAINER_TAG ${CONTAINER_TAG:-""}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.