builder: handle cases where onbuild is not uppercase.

closes #8675 

/cc @tiborvass 
why use two image names? one should be sufficient, and you can reuse it by not using the cache.