Build only the images whose Dockerfiles are changed

Can we change our CI so that only the images that are changed in an MR are built? Maybe leverage changes https://docs.gitlab.com/ee/ci/yaml/#onlychangesexceptchanges.