I have a build target for clean/verbose, but it's not propagating properly:
clean:
$(eval export CLEAN_BUILD:=--no-cache)
verbose:
$(eval export DOCKER_VERBOSE:=BUILDKIT_PROGRESS=plain)
docker.stop.rebuild:
make -j 2 docker.build docker.stop
docker.build:
$(DOCKER_VERBOSE) docker compose build $(CLEAN_BUILD) $1
My goal is to be able to say make clean verbose docker.stop.rebuild and have the final commands run differently than they would if I had run make docker.stop.rebuild without the other targets.
It seems like those variables are not sticking. Sometimes it works as I expected, and other times it works for part of the docker build and then stops working. I've tried a bunch of permutations (= vs :=, using shell, using && to try and force it to pass on the rebuild goal, etc.)
So I tried this, based on this thread: Export environment variables from makefile to shell
clean: CLEAN_BUILD:=--no-cache
verbose: DOCKER_VERBOSE:=BUILDKIT_PROGRESS=plain
But when I do that, I get this error:
Makefile:81: *** recipe commences before first target. Stop.
Any idea why? I've tried with GNU Make 4.3 and 4.4.1 and both have this behavior.