DEV Community

Discussion on: How to deploy python-ldap in Production Docker Image

Collapse
 
florian_courouge profile image
Courouge

Hi, nice post, I try it to in this way:
github.com/Courouge/fastapi-apps/b...
What to you think ?

Collapse
 
naderelshehabi profile image
Nader Elshehabi

Thanks for sharing. Looks like you've put a lot of effort in it. Well written.

I haven't tried the Dockerfile, but I'm wondering why do you need a virtual environment inside the container, and why two stages for build?

Collapse
 
florian_courouge profile image
Courouge

I use multi-stage build to reduce image size and benefit layer caching. In case of virtual environment, I just divide the build stage with pip dependencies and the run stage to reduce attack surface. I'm not a expert on this part but you could find some links that explain why I am using multistage :)
sysdig.com/blog/dockerfile-best-pr...
docker.com/blog/containerized-pyth...

Collapse
 
agritheory profile image
Tyler Matteson

@florian_courouge I'm interested in understanding why you decided to use a combination of a debian and distroless base images.

Collapse
 
florian_courouge profile image
Courouge

In short answer, debian for building ordinary packages and distroless to reduce vulnerabilities (and docker image size in some cases). These base images are stable unlike alpine base.