These instructions walk you through using Raygun to generate a new app, pushing it to GitHub, deploying it to Heroku (two envs: production and acceptance), and setting up continuous integration and deployment using CircleCI. There's a preference for command-line operations when possible.
- Homebrew
- Heroku toolbelt (
brew install heroku-toolbelt
) - Postgres installed (
brew install postgres
) and running - Postgres superuser called 'postgres' (
createuser -s postgres
) - PhantomJS installed (
brew install phantomjs
) - GitHub gem (
gem install hub
)
#-------------------------------
# Install Prequisites
brew install heroku-toolbelt postgres phantomjs # be sure to init and start postgres
createuser -s postgres # generic db superuser
gem install raygun hub
#-------------------------------
# Generate the app and database setup
raygun bee-tracker # you should use something different/unique
cd bee-tracker
./bin/setup
# Run the specs, they should all pass
RAILS_ENV=test rake
# Check out the running app locally
foreman s
open http://locahost:3000
#-------------------------------
# Push it to GitHub
hub create
git push
#-------------------------------
# Deploy "production" to Heroku
heroku apps:create bee-tracker
git remote rename heroku production
git config remote.production.push master:master
git push production
heroku run rake db:migrate db:seed
# Kick the tires...
open http://bee-tracker.herokuapp.com
#-------------------------------
# Deploy "acceptance" to Heroku
git co -b development
git push -u origin HEAD
heroku fork -a bee-tracker bee-tracker-acceptance
heroku config:set RACK_ENV=acceptance RAILS_ENV=acceptance -a bee-tracker-acceptance
git remote add acceptance https://git.heroku.com/bee-tracker-acceptance.git
git config remote.acceptance.push development:master
git push acceptance
heroku run rake db:migrate db:seed -a bee-tracker-acceptance
# Kick the tires...
open http://bee-tracker-acceptance.herokuapp.com
Follow these steps using the CircleCI web UI:
- Visit http://circleci.com.
- Authenticate with GitHub.
- Follow the git repo.
- Open up the project settings, select Heroku, set Heroku API Key and the Heroku deploy user.
- Retry the build when/if it fails during deploy (Heroku settings were missing).
Changes to development are deployed to acceptance when they pass CI. Changes to master are deployed to production.
Viola! You have a shiny new Rails app on GitHub, Heroku (prodction and acceptance), and CircleCI. New commits are automatically tested and deployed. Win!
I've really enjoyed using the parity gem for making heroku commands easier. One issue is that it requires production to be named
<APPNAME>-production
, and you have to write a small script to support the acceptance environment (rather than staging). The upside is that you can sayproduction console
rather thanheroku run rails console --app my-app