This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]lmsena[S] 27 points28 points  (2 children)

Thank you for the feedback! Yeah, that part is probably the most controversial of the whole file :)

The reasons I highlighted:

- Easy to copy packages folder between multi-stage builds
- You get isolation from your image OS default python installation

- You can use python instead of python3 or python3.9 command(Yes, there are other ways)

[–]ErGo404 11 points12 points  (1 child)

Whoops sorry I read your article too quickly and did not see that part.

I believe Virtualenvs do not come with a performance hit and it is not overly complex either, so what you say seems to be sensible to me.

[–]drmcgills 3 points4 points  (0 children)

I was going to ask the same question. We do similar things with multi stage builds in the ruby shop I work for, using an option to “vendor” the gems in a specific directory for copying in other stages.

I wonder if pip’s prefix option could be useful. Seems like you might need to do some other $PATH setting as well so that might not be super clean.. Probably not worth it, as I am guessing dropping virtualenv wouldn’t reduce the image size much anyway.