halloo, i am trying to build a docker image that o will deploy on fly.io which accept only images under 2gb, i have libraries such sentence-transformers , flask , numpy , json , but then while am building the image also torch and a lot dependencies are being installed and am getting a size of 6GB, is there any way to make it under 2?
this is my docker file : FROM python:3.9-slim AS build
Format your post with 3 backticks before and after code/config.
This is not really a Docker question, it’s about your application and dependencies. You need to check if you really need everything, even build-essential?
So you are building a multi-stages images and the last one is built from a slim one. That’s perfect.
Did you have an idea about the disk size of the usr/local/lib/python3.9/site-packages folder ? À priori, this is the only location where you can intervene. And thus did you really need all your python librairies ? (if you’re building the final production image then all dev dependencies can be dropped)
Furthermore, for every package that already existed in the images /usr/local/lib/python3.9/site-packages directory, you high likely end up having the same packages just with differing metadata and the additional new packages from the build stage n the new layer of the final image.