Created
March 22, 2016 15:46
-
-
Save biggers/5302a01c270ee83426ad to your computer and use it in GitHub Desktop.
GNU Makefile for docker-compose work
This file contains hidden or 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
## -*- makefile -*- | |
## [email protected], Mark Biggers | |
## GNU Makefile for docker-compose build & run of a Python or other Project | |
## | |
## REFs: | |
## https://docs.docker.com/compose/reference/ | |
## https://github.com/docker/compose/releases | |
## | |
## NOTE: you need to use real tabs, not spaces, in a Makefile! | |
.PHONY: build_image start stop getlogs clean | |
# use with "remake" on Ubuntu! See GNU Makefile docs on ONESHELL | |
.ONESHELL: | |
DCMP = docker-compose | |
# --pull downloads a new base-image | |
PULL = # "--pull" | |
build_image: | |
${DCMP} build --force-rm ${PULL} | |
build_image_bust: | |
date '+%F:%H.%M.%S' > cache-stamp | |
${MAKE} build_image | |
start: | |
${DCMP} up -d | |
stop: | |
${DCMP} stop | |
# to help debug a failed build. set -o ignoreeof | |
IMAGE_ID = foo | |
run_debug: | |
docker run -i -t ${IMAGE_ID} /bin/bash | |
run_bash: | |
docker exec -t -i ${IMAGE_ID} bash -l | |
getlogs: | |
${DCMP} logs | |
real_clean: | |
echo "exited Dockers: $$(docker ps -aq -f status=exited)" | |
# docker rm -v $(docker ps -aq -f status=exited) | |
# '-v' incls Docker volumes | |
RMFLAGS = | |
clean: | |
${DCMP} rm ${IMAGE} ${RMFLAGS} | |
## on Linux or Mac OS-X | |
## https://docs.docker.com/machine/install-machine/ | |
machine-install: | |
curl -L https://github.com/docker/machine/releases/download/v0.6.0/docker-machine-`uname -s`-`uname -m` > /usr/local/bin/docker-machine | |
chmod +x /usr/local/bin/docker-machine |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment