Pre-load Python libraries inside Docker image?

Hi everyone,

Seeking some tips / guidance on the following.

We are deploying a Streamlit app using a simple Docker container, and when the app runs some libraries take a few seconds to be imported upon initial load (making user wait for a while). We want to avoid that.

Is there a way to “pre-load” Python libraries inside a Docker image so they can be used in the Streamlit app right away?

My thoughts lean towards using something like ENV PYTHONSTARTUP in the Dockerfile, but not sure if this is possible. Maybe there is another way to circumvent slow imports?

Thanks in advance!