When you write:
run: build docker run -v $(CURDIR)/project:/project app-server
in the makefile, make expects this recipe to create a file called run . make will check this fileโs timestamp against the timestamp of its required files to determine if this recipe should be repeated next time.
Similarly with the build tag that you have in your makefile.
build: Dockerfile docker build -t app-server .
However, none of these recipes creates files with the name of the target. This means that make cannot use the timestamp of this file to determine if the recipe needs to be run again. Since such a make should assume that it needs to re-run the recipe (because assuming it is different, this rule will never work).
If you run make -rRd , you will see what makes your thoughts, and you should see what I just said.
So the solution to your problem is to create stamp files for each of these purposes.
Just adding touch $@ (optionally with the @ prefix to make it turn off by default the execution of the echo of the commands that it runs) for each of these should be enough to make you work for you.
We believe that it makes sense to put sudo on each line of the recipe that it needs, instead of running make with sudo , if you do not want the stamp files to also be root.
For the record, this is discussed in the GNU Make Manual in section 4.8 Empty Target Files to Record Events .
source share