|
|
|
|
|
by weberc2
2805 days ago
|
|
Sorry if I'm a little dense; that doesn't seem like it solves any problems. It just says "use virtualenv and/or docker". I guess I was hoping for "how to manage dependencies in a localdev-friendly way for a Python/Docker app" or something. |
|
We just use a requirements.txt [1] for each service and run pip with the -r flag in the dockerfile. No Virtualenv in the container.
Most of the time we run these containers with docker-compose locally, but sometimes we want to run the service outside the container. For that we create a virtualenv outside the folder where we keep the source for the service. The reason for that is that we don't want to accidental copy the virtualenv in to the container. It wouldn't do much there but it would increase the container size.
You can do this easily with just "python3 -m venv", but there are some tools that help with that as well. I personally use pyenv-virtualenv [2] which just keeps all virtualenvs in ~/.pyenv/versions/<env>, but there is also conda [3] and virtualenvwrapper [4] which also store the virtualenvs in a central directory.
I am not sure if there really is any more to it.
[1]: https://pip.pypa.io/en/stable/user_guide/#requirements-files
[2]: https://github.com/pyenv/pyenv-virtualenv
[3]: https://conda.io/docs/user-guide/getting-started.html#managi...
[4]: https://virtualenvwrapper.readthedocs.io/en/latest/