Heroku and Github integration (how to structure the project)
I want to have the following directory structure:
/project .git README <-- project readme file TODO.otl <-- project outline ... <-- other project-related stuff /my_rails_app app config ... README <-- rails' readme file
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?
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
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.
4 Solutions collect form web for “Heroku and Github integration (how to structure the project)”
Here’s a simple solution that may or may not work for you.
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.
Add the Rails app project as a git-submodule within the “container” project.
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.
A solution for the Heroku situation (not the README file):
If you’re using the new Heroku Cedar (I believe it wasn’t available when you first asked your question) then your processes (like the rails server process) start up using Foreman. Thus, you can place a
Procfile in the root github directory that looks like this:
my_rails_app/script/runserver.sh could be a simple
#!/bin/sh cd my_rails_app bundle exec rails server -p $PORT
Locally, you should also create a file called
.env (note the . at the beginning), which contains
This file is read by foreman and used to set environment variables so that the port is set when you execute
foreman start on your machine (from the root github directory, where the Procfile lies). The Heroku server takes care of the .env file on your dyno. The big advantage is you can set up multiple processes on the dyno that way!
Just overwrite Rails’ default
README file. There’s no reason to keep it around. Put your other project-management-related stuff in the
doc directory. While you certainly have valid reasons for wanting to set it up the way you did, you’re just creating a headache for yourself by going against convention, and it’s probably not worth the benefit.
I would add everything underneath
/my_rails_app to the Heroku git repository. Then add GitHub as a remote and add everything underneath
/project to the GitHub repository. Then you can push the Rails application to Heroku (from
/my_rails_app) and push the full project to GitHub (from