cjolowicz / cookiecutter-hypermodern-python

Hypermodern Python Cookiecutter
http://cookiecutter-hypermodern-python.readthedocs.io/
MIT License
1.8k stars 232 forks source link

[Feature Request] Setup the environment and poetry to work with Docker #1201

Open Mithrandir2k18 opened 2 years ago

Mithrandir2k18 commented 2 years ago

I really like this template and have been using it for a while, but it seems to have one critical blindspot: Supporting and switching between multiple python versions. Sure it's possible to kind of slap on pyenv and work with that, but I personally have found these external python-version management systems(like pyenv and anaconda) kind of cludgy, especially when it comes to cleaning up after moving to a different project.

Docker on the other hand makes that super-simple. Even if you don't cleanly specify to delete all intermediate containers, one can always do docker system prune and all cleanup should be done. I don't think I have to list all benefits of using Docker during development here.

I have however struggled to setup docker in combination with poetry, let alone adding debugging in VSCode. Poetry also doesn't seem to have documentation about it.

Would it be possible to add Docker support (as an option)?

Coinhexa commented 2 years ago

Before you add a Dockerfile you might wanna read this https://luis-sena.medium.com/creating-the-perfect-python-dockerfile-51bdec41f1c8

Mithrandir2k18 commented 2 years ago

@Coinhexa I'd much rather be able to develop, run and test my code in the dockerfile(s) that I plan to ship or push for automated tests, not have another extra "one size fits all" image to carry around and maintain. My pre-poetry workflow, was (similar to) just having a package-list.txt to install system packages and a normal requirements.txt for python in my project and build a fresh docker image with those. For development I just use the VSCode docker extension.

In any case, docker seems like a weird exclusion here.

ianepreston commented 1 year ago

Not sure if this should be attached to this issue or have a separate one created, please let me know.

I don't mind using pyenv for multiple python versions, but I have found it challenging to ensure the system dependencies are all in place to support it, either for myself on a new machine or for another person I'm trying to help onboard.

To address this I've been working on building a dev container spec that will have everything in place to start using this template. You'd still be using pyenv within the project, but I think it would address the above concern about nicely cleaning up your environment, as well as my issue of reliably creating the environment to begin with.

If there's broader interest in this approach I'm happy to contribute to getting the dev container spec added to this template.

Mithrandir2k18 commented 11 months ago

See poetry+docker efforts.