Skip to content

Deploying maphub on Heroku

behas edited this page Oct 24, 2012 · 4 revisions

Remember to add --app <app_name> at the end of your commands to make sure you're working on the right Heroku App

Heroku setup

(Borrowed from Ruby on Rails Tutorial)

After signing up for a Heroku account, install the Heroku gem:

gem install heroku

When using Heroku you will need to create SSH keys if you haven’t already, and then tell Heroku your public key so that you can use Git to push the sample application repository up to their servers:

heroku keys:add

Create a new application at Heroku:

heroku create

If you want to deploy maphub in multiple environments (e.g., staging, production), you can assign names to your git remotes.

heroku create --remote production

Prepare maphub for deployment

Precompile JS-assets locally and commit

RAILS_ENV=production bundle exec rake assets:precompile
git add public/assets
git commit -m "pre-compiled JS-assets for deployment"

Deploy maphub on Heroku

Push production code to Heroku

git push heroku master

... or if you have multiple deployment environments

git push production master

Push experimental branch

git push experiment 0.3-experiments-deploy:master

Administrating the deployed app

If maphub has already been deployed, reset the remote database (see below)

Create the database; populate production map data

heroku run rake db:migrate --app <app_name>
heroku run rake db:seed --app <app_name>

Reindex map data

heroku run rake sunspot:solr:reindex

Import remote database into your local development environment using Taps

heroku db:pull --remote experiment

Link local environment to remote environment (replace project with the name of your Heroku project)

git remote add heroku git@heroku.com:project.git

Resetting the Heroku Database

Find the Database Info:

heroku pg:info --app maphub-experiment

Should look like this:

=== HEROKU_POSTGRESQL_BLACK_URL (DATABASE_URL)
Plan:        Dev
Status:      available
Connections: 0
PG Version:  9.1.5
Created:     2012-08-17 02:13 UTC
Data Size:   6.4 MB
Tables:      8
Rows:        36/10000 (In compliance)
Fork/Follow: Unavailable

Resetting the database:

heroku pg:reset HEROKU_POSTGRESQL_BLACK --app maphub-experiment

Now migrate into the database as you normally would.