I am looking for a way to create multistage builds with python and Dockerfile:
For example, using the following images:
1st image: install
I recommend the approach detailed in this article (section 2). He uses virtualenv so pip install stores all the python code, binaries, etc. under one folder instead of spread out all over the file system. Then it's easy to copy just that one folder to the final "production" image. In summary:
Compile image
pip install xyz
as usual.Production image