英文:
can I start docker-compose within a pip package?
问题
我正在进行一个项目,其中包括一个docker-compose.yml文件(带有发布的公共docker镜像),以及环境文件。
通常,用户会执行以下步骤:
git clone
存储库- 对环境文件进行必要的更改
- 运行
docker-compose up
- 弄清楚配置更改的问题。回到步骤2。
- 最终感到满意
由于与Docker一起工作并为非开发人员更改变量可能有点繁琐,我想知道是否可以将整个存储库打包成一个Python wheel/pip可安装的软件包,以通过以下方式改善用户体验:
pip install mypackage
(这也会安装docker-compose等)mypackage start --variant=two --path=/home/
(自动执行配置更改)- 感到满意
是否可以使用Python wheel来实现这样的功能,或者是否需要一些黑魔法和/或是否被视为安全风险/不建议?
英文:
I am working on a project which consists of docker-compose.yml file (with published public docker images) together with environment files.
Typically, a user would
git clone
the repo- make the necessary changes to the environment files
- run
docker-compose up
- Figure out whats wrong with his config changes. Go to step 2.
- Eventually be happy
As working with docker and changing variables for non-devs can be a bit tedious, I was wondering if its possible to wrap the entire repo in a python wheel/pip installable package to improve the UX by allowing the user to;
pip install mypackage
(which would also install docker-compose etc.)mypackage start --variant=two --path=/home/
(does the config changes automatically)- Be happy
Is it possible to do something like this with python wheel or does it require some black magick and/or is this considered a safety risk/not recommended?
答案1
得分: 2
开始一个服务直接从pip安装是危险的。通过pip安装一个包和调用/运行它是两回事,我认为它需要由用户的意愿分开进行,而不是自动进行(这种情况很少见)。
如果你想将这个包装起来,并且只在你自己的环境中使用,那是你的选择,但总的来说,这是一个不好的主意,尽管它看起来像是一种改进。
我会使用一个单独的脚本来通过pip拉取,然后运行需要运行的内容。
话虽如此,你应该能够通过pip-run来完成安装和运行。
英文:
starting a service right out of the pip installation is dangerous
One thing is for you to install a package via pip, another is to invoke/run it, which by my opinion needs to happen separately by the intention of the User, not automatically (which would rarely be the case).
If you want to wrap this and use ONLY within your own environment, that is up to you, but overall this is a bad idea, although it seems as an improvement.
I would use a separate script to pull via pip, and then run whatever needs to run
Having said that, You should be able to accomplish the install land run with pip-run
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论