Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deploy a subdirectory to Heroku

Tags:

I have one 'super' repository in GitHub which will contain several applications I would like to deploy to Heroku. Here is an example of my repository.

/app
  /.git
  /website <-- would like to deploy this to Heroku

When I try to push using the following command:

$ git push heroku master

I get the following error:

Heroku push rejected, no Rails or Rack app detected.

How do I deploy a subdirectory to Heroku?

like image 412
Jamie Wright Avatar asked Jun 21 '10 01:06

Jamie Wright


People also ask

Can you push a branch to Heroku?

To deploy your app to Heroku, use the git push command to push the code from your local repository's main branch to your heroku remote. For example: $ git push heroku main Initializing repository, done.

Can I deploy a private repo to Heroku?

Heroku Button is no longer limited to source code hosted in public GitHub repos. It now works with both public and private GitHub repos.


1 Answers

This can be accomplished by putting a config.ru in your root directory that tells Heroku where to find your app. For example, with Rails 3, try a config.ru like this in your root directory:

WEBSITE_SUBDIR = 'website'
require "#{WEBSITE_SUBDIR}/config/environment"
run YourApplicationName::Application

And on Rails 2.x, you'll need something like this:

WEBSITE_SUBDIR = 'website'
require "#{WEBSITE_SUBDIR}/config/environment"
use Rails::Rack::LogTailer
use Rails::Rack::Static
run ActionController::Dispatcher.new
like image 99
Adam Wiggins Avatar answered Oct 15 '22 17:10

Adam Wiggins