Reduce size of Docker image
Using multi-stage build avoids that development and intermediate files increase the image's size. Multi-stage build allows just copying the compiled files to the final image without the intermediate layers.
Reduces the image's size from 8.99GB to 7.47GB.
Note: I haven't extensively tested whether the new image breaks something yet.
If there's a need, I can update the pytorch Dockerfile too.
Thanks for the PR - this seems like a good idea. I'll run some tests to ensure nothing breaks, and if all is good, we should do this for the PyTorch dockerfile too.
Just a quick update - I did have some issues with this multi-stage approach during initial testing, which is why I haven't been able to merge quite yet. I'll keep working on it and provide an update once I have a solution.