The problem is we call $(MAKE) which calls and forks make without carrying variables over. This is fixed by using export.
The second problem is that make has rules for variable expansion. = and ?= are considered "recursively expansions" which you can think of as lazily evaluated. := is considered "simply expanded" and is evaluated at declaration time. This is what we want to ensure it's only evaluated once.
Now that we export the value correctly to targets, we need to make sure we don't override it, so we add the conditional.
We still use the latest tag for e2e tests because we need this for the e2e-only target which does not rebuild all images. This needs to be conditional so I'll fix this in a separate PR.
I added nanoseconds to the tag which helps with testing but also better so we reduce the odds of mutating tags for older images.
tl;dr: this ensures that when you run
make e2e
, all Docker images are built with the same tag.Another try for https://github.com/GoogleCloudPlatform/prometheus-engine/pull/845 (thanks @pintohutch)
How this works
$(MAKE)
which calls and forksmake
without carrying variables over. This is fixed by usingexport
.make
has rules for variable expansion.=
and?=
are considered "recursively expansions" which you can think of as lazily evaluated.:=
is considered "simply expanded" and is evaluated at declaration time. This is what we want to ensure it's only evaluated once.e2e-only
target which does not rebuild all images. This needs to be conditional so I'll fix this in a separate PR.