alpine-python icon indicating copy to clipboard operation
alpine-python copied to clipboard

Build deps removal dilemma

Open ykshatroff opened this issue 5 years ago • 1 comments

This is not a bug on its own, but rather a question of efficiency.

If I add some python library that requires binary objects to be built or run (examples: lxml requires libxml2 and libxslt, postgres psycopg2 requires libpq to run and postgresql-dev to build, etc) then I would have to essentially repeat all the installation and removal rituals in my descendant image. At the same time it would be more efficient to just have a custom dockerfile with the cleanup done once in the last stage of the build, and just docker-squash the resulting image.

Currently I see several ways out of this dilemma:

  • provide template dockerfiles for that particular approach, where you could edit the dockerfile, adding the necessary libraries between the build tools installation command and the cleanup, and let the user squash the image after build;
  • add an ARG so that the installed tools would be controlled (added) by this build time argument, and this would not even require squashing the image.

There might be other ways of doing it, any ideas/suggestions?

ykshatroff avatar Dec 19 '19 16:12 ykshatroff

I think the better way is to just have another image that builds on this one. I think this situation is the same issue I had, and that lead me to build docker-alscipy. Is this the case, correct me if I'm wrong.

I feel that the template approach would lead to the same problem, which is you would have to build them anyways. The ARG argument might be solved with the slim tag but that also requires the image to be built, and don't change that.

Any other ideas?

jfloff avatar Mar 27 '20 14:03 jfloff