Skip to content

Instantly share code, notes, and snippets.

@biggers
Created March 22, 2016 15:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save biggers/5302a01c270ee83426ad to your computer and use it in GitHub Desktop.
Save biggers/5302a01c270ee83426ad to your computer and use it in GitHub Desktop.
GNU Makefile for docker-compose work
## -*- makefile -*-
## biggers@utsl.com, 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