I was implementing the script from the following posts. Since it´s a bit old i wanted to open this new thread as i have a problem when running the makefile.
Basically i have created a top level makefile that will compile a seet of docker images in subfolders.
makefile - build mulitple files with multiple targets
# Assuming each subdirectory containins a Dockerfile
IMAGES := $(patsubst %/,%,$(dir $(wildcard */Dockerfile)))
BUILD_TARGS = $(patsubst %,build_%,$(IMAGES))
TEST_TARGS = $(patsubst %,test_%,$(IMAGES))
PUSH_TARGS = $(patsubst %,push_%,$(IMAGES))
VERSION := 1 # $(shell git rev-parse --short=12 --verify HEAD)
DOCKER_REPO_URL := david.io/reponame
define docker_build =
build_$(1):
@echo "Building $(1)"
#docker build -t $(1) --force-rm $(1)
endef
define docker_test =
test_$(1):
@echo "Testing $(1)"
#docker inspect $(1)
#docker run --rm $(1) help
endef
define docker_push =
push_$(1):
@echo "Pushing $(1)"
#docker tag $(1) $(DOCKER_REPO_URL):$(1)-$(VERSION)
#docker push $(DOCKER_REPO_URL):$(1)-$(VERSION)
#docker tag $$@ $(DOCKER_REPO_URL):$(1)
#docker push $(DOCKER_REPO_URL):$(1)
endef
.PHONY: all build test release clean $(IMAGES) $(BUILD_TARGS) $(TEST_TARGS) $(PUSH_TARGS)
all: build test release
build: $(BUILD_TARGS)
$(foreach image,$(IMAGES),$(eval $(call docker_build,$(image))))
#test: $(TEST_TARGS)
# $(foreach image,$(IMAGES),$(eval $(call docker_test,$(image))))
#release: $(PUSH_TARGS)
# $(foreach image,$(IMAGES),$(eval $(call docker_push,$(image))))
I have the following error:
makefile:37: *** prerequisites cannot be defined in recipes. Stop.