简体   繁体   English

开发Django可重用应用程序时,如何部署到Heroku?

[英]When developing a Django reusable app, how to deploy to Heroku?

I'm trying to develop a Django reusable app and a project that uses it. 我正在尝试开发Django可重用应用程序和使用它的项目。 They are in two separate git repositories. 它们位于两个单独的git存储库中。 The goal is to make it easy to change the code of both the project and the app, and deploy that code to Heroku. 目的是使更改项目和应用程序代码以及将代码部署到Heroku变得容易。

Right now, I've set up the requirements.txt of the project to include the line 现在,我已经设置了项目的requirements.txt以包括以下行

https://github.com/me/my-reusable-app/tarball/master

So, theoretically, I can work on my reusable app, push the changes to github, and then deploy from the project directory. 因此,从理论上讲,我可以使用可重复使用的应用程序,将更改推送到github,然后从项目目录进行部署。 However, Heroku doesn't seem to notice when I have made changes to my-reusable-app . 但是,当我对my-reusable-app进行更改时,Heroku似乎没有注意到。 Even when I change the project, check in the changes, and then run git push heroku master , forcing a rebuild, it doesn't seem to catch the updates from GitHub. 即使当我更改项目时,检查所做的更改,然后运行git push heroku master ,强制进行重建,它似乎也无法捕获来自GitHub的更新。

Is there a better way of doing this? 有更好的方法吗? For instance, would it be better to make the app a git submodule of the project, rather than having a dependency in requirements.txt ? 例如,将应用程序设为项目的git submodule ,而不是依赖于requirements.txt会更好吗? Or I could also deploy without git, using this tool . 或者,也可以使用此工具在不使用git的情况下进行部署。 Finally, I could give up on the app being reusable, and just move the two git repositories together. 最后,我可以放弃可重复使用的应用程序,而只需将两个git存储库一起移动即可。

I would recommend a Git submodule. 我会推荐一个Git子模块。

I am successfully using this approach to include Twitter Bootstrap source code into a Django application on Heroku, and since submodules are widely understood (if not universally liked) other developers should have minimal trouble getting up to speed. 我已经成功地使用这种方法将Twitter Bootstrap源代码包含在Heroku上的Django应用程序中,并且由于子模块得到了广泛的理解(如果不是普遍喜欢的话),其他开发人员应该不费吹灰之力就能上手。

But of course there are other options. 但是,当然还有其他选择。 This Heroku article suggests four, including the one I recommend: Heroku的这篇文章提出了四个建议,其中包括我推荐的一个:

  • Git submodules, Git子模块
  • "protected" Git submodules that require credentials for cloning, 需要凭据才能进行克隆的“受保护” Git子模块,
  • using a vendor/ directory, and 使用vendor/目录,以及
  • private package repositories. 私有软件包存储库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM