The python:3.10-slim base is the right call for a prediction API, and it's worth spelling out why, because the full image drags in build tooling you never touch at runtime and just widens the attack surface. Copying requirements and running pip install before the app code, like you show, is the caching trick that saves the most rebuild time. Are you pinning exact versions in requirements, or leaving them open for the latest patch?
Thanks! I'm glad you noticed that! Yes, I generally pin exact package versions in requirements.txt to keep builds reproducible and avoid unexpected changes from upstream updates. It makes deployments much more predictable, especially when collaborating with others or moving between environments.
Kartik N V J K
AI Developer | Making AI reliable, trustworthy & accessible to everyone | Active community contributor
The python:3.10-slim base is the right call for a prediction API, and it's worth spelling out why, because the full image drags in build tooling you never touch at runtime and just widens the attack surface. Copying requirements and running pip install before the app code, like you show, is the caching trick that saves the most rebuild time. Are you pinning exact versions in requirements, or leaving them open for the latest patch?