Put the things that are going to change as the last step; use very few steps (eg dont copy files one by one) and let Docker cache the results.
We use WhaleWare as a templating tool: https://github.com/l3nz/whaleware and it works great (or well enough)