provision/docker/flatten: refactoring function that checks whether an app needs flattening

This function now addresses the case when the app has zero deploys -
during the first deploy when the app.Deploy is not incremented yet
provision/docker/docker.go: running Flatten with goroutine in build time