How to reproduce
Suppose we have a file called Dockerfile:
If we run the command dockerfile-json --build-arg=foo=alpine Dockerfile, the tool correctly interprets that the base image to use is alpine.
However when we change the contents slightly:
FROM ubuntu
# ...
ARG foo
FROM $foo
then the tool will interpret the last step as {... "From": {"Image": ""}, ...} even with the passed --build-arg, which breaks base image parsing.
Expected behavior
The argument foo should be interpreted in the same way in both of these cases. I know this can be worked around by modifying the Dockerfile (pushing all ARGs to the top of the Dockerfile), but both of these formats are valid and only one of them is supported by dockerfile-json.