Refactored Dockerfiles as m4 templates and build scripts