If your Docker Python build requires system dependencies that are NOT required at runtime, structure your build as follows:
- Use a multi-stage build
- Stage 1 installs system dependencies and uses them to build local wheels
- Stage 2 begins from the same base as Stage 1, copies wheels from Stage 1, and installs the wheels
- The rest of your build will be based on Stage 2
If you follow these steps, you'll end up with the smallest-possible Python Docker container with all your Python dependencies intact.