Code exists in a branch of rpm-ostree:
https://github.com/cgwalters/rpm-ostree/commits/libhif-next-compose-dockerimages
Dockerfile is an imperative format that allows doing anything, and as a consequence the tooling around it (docker itself, rel-eng tools) are unable to accurately optimize.