-
Notifications
You must be signed in to change notification settings - Fork 57
Deploying to Heroku
The following instructions document the changes required to deploy Citizenry on Heroku.
$ git clone git://github.com/reidab/citizenry.git
To deploy Citizenry on Heroku, both config/settings.yml
and config/database.yml
must be present. Delete the entries from .gitignore
, rename the sample files, and commit the changes.
# Delete (or comment out) the entries for config/settings.yml and config/database.yml
$ vi .gitignore
# Rename the sample files
$ mv config/settings-sample.yml config/settings.yml
$ mv config/database-sample.yml config/database.yml
$ git commit -am "Adding settings and database"
Create To run Citizenry on Heroku, specify a Heroku stack running Ruby 1.8.7
$ heroku create citizenry-demo --stack bamboo-ree-1.8.7
Although Citizenry currently works with both MySQL and PostgreSQL, it is generally advised to keep the development and production environments as similar as possible. In other words, please don't use MySQL during development and PostgreSQL in production.
Choose your own adventure.
Congratulations, you chose wisely. Add the ClearDB addon and point DATABASE_URL
to CLEARDB_DATABASE_URL
# Add the cleardb addon (free MySQL)
$ heroku addons:add cleardb:ignite
# Grab the URL in CLEARDB_DATABASE_URL
$ heroku config | grep CLEARDB_DATABASE_URL
# Update DATABASE_URL with the URL (Note, use mysql*2*)
$ heroku config:add DATABASE_URL='mysql2:/.....'
Congratulations, you chose wisely. Add in the pg
gem, remove mysql2
, and update bundler.
# Add pg, remove mysql2
$ vi Gemfile
$ bundle update
The easiest way to install PostgreSQL is with Homebrew (http://mxcl.github.com/homebrew/)
$ brew install postgresql
Alternatively install from the binary: http://www.postgresql.org/
Setting up Thinking Sphinx on Heroku is beyond the scope of this article. Citizenry alternatively ships with an option to search with SQL (yes, I know @nz, I know). To remove Thinking Sphinx, remove thinking-sphinx
from the Gemfile, and configure config/settings.yml
to use SQL instead.
# Remove `thinking-sphinx` gem
$ vi Gemfile
# Set `search: sql`
$ vi config/settings.yml
$ bundle update
Citizenry uses Compass to emit CSS. To configure Compass for Heroku, update the css_dir
variable in config/compass.rb
then add a Rack handler to config.ru
Rack handler: use Rack::Static, :urls => ['/stylesheets/compiled'], :root => 'tmp'
# Update `css_dir = "tmp/stylesheets/compiled"`
$ vi config/compass.rb
# Just before `run...` add in the Rack handler (use Rack::Static, :urls => ['/stylesheets/compiled'], :root => 'tmp')
$ vi config.ru
Deploy and run the setup scripts
# Deploy
$ git push heroku master
# Setup database and all that jazz
$ heroku rake db:migrate
Don't forget to update settings.yml