Improve building of docker image
This improves the Dockerfile in 3 ways:
- deduplicates installing the dependencies
- moves more things to the builder stage so that no manual clean is necessary
- fix the requirements by using a script rather than a patch file to make it easier to upgrade