I have a Makefile that I am using to build and tag a docker image. I want to tag the built image with name and version info extracted from a file ("pyproject.toml"). My extraction mechanism is pretty simple, and works when run manually on the command line:
$ grep -e "^name\s*=\s*" pyproject.toml | cut -d = -f 2 | xargs
audio_program_generator
$ grep -e "^version\s*=\s*" pyproject.toml | cut -d = -f 2 | xargs
1.7.1.0
However, when I try to do the same using variables in a Makefile, they expand to nothing.
My pyproject.toml file looks like this:
[tool.poetry]
name = "audio_program_generator"
version = "1.7.1.0"
Relevant section of Makefile:
NAME:=$(grep -e "^name\s*=\s*" pyproject.toml | cut -d = -f 2 | xargs)
VERSION:=$(grep -e "^version\s*=\s*" pyproject.toml | cut -d = -f 2 | xargs)
build-apg:
docker build --target apg --tag $(NAME):$(VERSION) .
Expected output
$ make build-apg
docker build --target apg --tag audio_program_generator:1.7.1.0 .
Actual output:
$ make build-apg
docker build --target apg --tag : .
invalid argument ":" for "-t, --tag" flag: invalid reference format
See 'docker build --help'.
make: *** [build-apg] Error 125
What am I doing wrong?