可以在pip包内启动docker-compose吗?

huangapple go评论84阅读模式
英文:

can I start docker-compose within a pip package?

问题

我正在进行一个项目,其中包括一个docker-compose.yml文件(带有发布的公共docker镜像),以及环境文件。

通常,用户会执行以下步骤:

  1. git clone 存储库
  2. 对环境文件进行必要的更改
  3. 运行 docker-compose up
  4. 弄清楚配置更改的问题。回到步骤2。
  5. 最终感到满意

由于与Docker一起工作并为非开发人员更改变量可能有点繁琐,我想知道是否可以将整个存储库打包成一个Python wheel/pip可安装的软件包,以通过以下方式改善用户体验:

  1. pip install mypackage(这也会安装docker-compose等)
  2. mypackage start --variant=two --path=/home/(自动执行配置更改)
  3. 感到满意

是否可以使用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

  1. git clone the repo
  2. make the necessary changes to the environment files
  3. run docker-compose up
  4. Figure out whats wrong with his config changes. Go to step 2.
  5. 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;

  1. pip install mypackage (which would also install docker-compose etc.)
  2. mypackage start --variant=two --path=/home/ (does the config changes automatically)
  3. 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

huangapple
  • 本文由 发表于 2023年7月17日 21:26:42
  • 转载请务必保留本文链接:https://go.coder-hub.com/76704949.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定