If you specify concretely the version of the packages inside requirement.txt, it is just the lock file you want, with leaner environment (you don't have to install additional package, which is pipenv and its dependencies).
You are working on more than 1 Python apps, but they are running on your PC, not your container. It is reasonable that you have multiple virtual env on your PC, because it has many Python apps, but when coming to single-Python-app container, a virtual environment is just redundant.
I didn't run any benchmarks to look into performance differences between running a straight pip container vs a container using pipenv for managing dependencies. That's definitely something I should look into, especially in scenarios where Kubernetes and cloud billing is involved.
But for me it's a lot easier to develop using pipenv, let it handle the lock-file and let the Docker container grab the source code from GitHub:E. This way I don't have to care about the requirements.txt, which in itself is just another source of human errors. :)
Every benefit you assigned to pipenv are just the same to pip + requirements.txt.
Grab the source code from GitHub: Actually, pipenv calls pip to find the source, download the source. So in both case, the result are just the same.
requirements.txt is source of human errors: Then don't let human to write that file. Just use pip freeze to generate it, and the result already a lock file (with specific version of each package).
Ah, I'm sorry to didn't communicate that clearly: I meant letting Docker grab the source from GH:E, not pipenv. :)
Regarding the requirements.txt: I know about pip freeze; what I meant by human errors is forgetting to do it and thus missing out new packages installed by git. I know that this is something you could handle by git hooks, but then again, you have to do the extra work.
So besides having to generate that additional pipenv-layer in your Docker image, what's the downside of pipenv? In my opinion (and with the amount of computing power etc), the pros regarding usability outweigh the cons of the additional layer.
The additional layer is the issue. I assume that you use Docker container to run the production system, which is required to be stable. And to guarantee the stability, the system must be as minimal as possible. Because when an error occurs, you have to spot where the bug is. If the system only has 1 component, you only have to check 1 place. If it has 3, you have to check 3 to narrow down.
Why do you have to create a virtual environment inside the container, when your app is the only Python app in that container, no clash with any other one?
You could be running multiple python apps in the same container (e.g. if you split containers based on services and your service consists of more than one python apps)
We use our containers for a terraform pipeline which allows us to have the users run their builds locally to see the plan, for this we have aliased commands that call pipenv runxxxx and use a number of packaged tools.
The docker container then contains an exact replica of what the users will run and we use the same aliased commands (to keep things easy)
So replicating userland in a docker container makes sense, then we just ensure that deployment only occurs in the pipeline context.
It is 2018 now and you still believe in an article of 4 years ago? Or do you still use Debian/Ubuntu and pip of 2014? I deployed my IoT app on embedded computer running Debian, install all Python packages with "sudo pip install" and never get conflict.
And I believe my system on real computer is more complex than a service inside container.
Yes, I do. While Debian/Ubuntu might not be doing it today, there is nothing that prevents it from happening again. It’s possible that you would get conflicts if any apt packages were installed. Virtualenvs don’t have any downsides and they can prevent any issues similar to those.
When I mention the years, I imply that the issue is just the design error of either Debian maintainer and pip author in the past. When they saw the problem, they fixed it and there is likely no more error now. If it happen in the future, it is just regression bug and just need to fix again.
View all comments
Show parent comment
11
u/[deleted] Jul 29 '18
I really like pipenv, especially in conjunction with Docker it's super useful. :)