squash layers (inspired by discourse_docker)