Heroku 和 Github 集成(如何构建项目) [英] Heroku and Github integration (how to structure the project)

查看:25
本文介绍了Heroku 和 Github 集成(如何构建项目)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个网络服务,我想将源代码存储在 github 上并在 heroku 上运行该应用程序.到目前为止,我还没有在网络上的任何地方看到我的确切场景,所以我会在这里问:

I'm creating a webservice and I want to store the source on github and run the app on heroku. I haven't seen my exact scenario addressed anywhere on the 'net so far, so I'll ask it here:

我想要以下目录结构:

/project
  .git
  README <-- project readme file
  TODO.otl <-- project outline
  ... <-- other project-related stuff
  /my_rails_app
     app
     config
     ...
     README <-- rails' readme file 

上面的project对应的是http://github.com/myuser/project,而my_rails_app 是应该推送到 heroku 的代码.我是否需要为 rails 应用程序创建一个单独的分支,还是缺少一种更简单的方法?

In the above, project corresponds to http://github.com/myuser/project, and my_rails_app is the code that should be pushed to heroku. Do I need a separate branch for the rails app, or is there a simpler way that I'm missing?

我猜我的项目相关的非 Rails 文件可能存在于 my_rails_app 中,但是 rails README 已经存在于那里,覆盖它似乎不一致.但是,如果我离开它,我的 rails 应用程序的 github 页面将包含 rails 自述文件,这毫无意义.

I guess my project-related non-rails files could live in my_rails_app, but the rails README already lives there and it seems inconsistent to overwrite that. However, if I leave it, my github page for the rails app will contain the rails readme, which makes no sense.

另外……我试着按照上面的描述进行设置并运行

Also ... I tried just setting it up as described above and running

git push heroku

来自主项目文件夹.当然,heroku 不知道我要部署子文件夹:

from the main project folder. Of course, heroku doesn't know I want to deploy the subfolder:

-----> Heroku receiving push
 !     Heroku push rejected, no Rails or Rack app detected.

推荐答案

这里有一个简单的解决方案,可能适合您,也可能不适合您.

Here's a simple solution that may or may not work for you.

  • 在 GitHub 上创建两个项目.一个项目应该只是 Rails 应用程序(即 Rails 应用程序目录中的所有内容).另一个项目应该是 Rails 应用程序目录之外的所有内容.

  • Create two projects on GitHub. One project should be just the Rails app (i.e. everything inside the Rails app directory). The other project should be everything outside the Rails app directory.

将 Rails 应用项目作为 git-submodule 添加到容器"项目中.

Add the Rails app project as a git-submodule within the "container" project.

现在您可以将 Heroku 作为远程单独添加到 Rails 应用程序存储库中并将其推送到 heroku.Heroku 将接受推送,因为它只是一个带有预期目录和文件的 Rails 应用程序.

Now you can add Heroku as a remote on the Rails app repository separately and push it to heroku. Heroku will accept the push because it is just a Rails app with the expected directories and files.

这篇关于Heroku 和 Github 集成(如何构建项目)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆