I have following Makefile target defined:
.PHONY: docker-build
docker-build:
# Build Docker image
docker build \
--squash \
...
-t $(DOCKER_IMAGE):$(DOCKER_TAG) .
output:
@echo Docker Image: $(DOCKER_IMAGE):$(DOCKER_TAG)
I need to use the variables DOCKER_IMAGE and DOCKER_TAG as input for another script to run right after the make docker-build.
Do you have any idea how to do it? Thanks in advance.
I have tried many ways but can't get the output from Makefile to environment variables or even just to terminal.
outputcommands to thedocker-buildrecipe, B) write the variables to a file which the output script -- or the output rule -- could read, or C) have thedocker-buildrule optionally call theoutputrule. Does any of those options appeal?make. This has nothing to do withmakeor makefiles. This is a fundamental feature of all POSIX programs: a program inherits its environment from its parent, and a program can never modify its parent's environment. So, the shell is a program, it invokes make (another program), and it's not possible for the child (make) to modify the environment of the parent (shell). Can't be done.