Skip to content

Instantly share code, notes, and snippets.

@vizowl
Last active August 29, 2015 14:16
Show Gist options
  • Save vizowl/5eb85d2d6ab2a6f463ac to your computer and use it in GitHub Desktop.
Save vizowl/5eb85d2d6ab2a6f463ac to your computer and use it in GitHub Desktop.
Makefiles that use container restarting to persist intermediates and targets
CID := .container
CONTAINER = $(shell cat $(CID) 2>/dev/null)
all: out.png
out.png: run/*
ifneq "$(CONTAINER)" ""
docker restart $(CONTAINER)
docker attach $(CONTAINER) || docker logs $(CONTAINER)
else
docker run --cidfile=$(CID) -w /work -v $$PWD/run:/work \
ipython/scipystack make $(MFLAGS)
endif
docker cp $(CONTAINER):/output/out.png .
clean:
ifneq "$(CONTAINER)" ""
docker rm $(CONTAINER)
endif
rm -f out.png $(CID)
/output/out.png: histogram.py image.jpg /output/.exists
python histogram.py
/output/.exists:
mkdir -p $(dir $@)
touch $@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment