A Capfile for Heroku Deploys (HowTo: Deploy to Heroku via Rake)

One of the most annoying issues I’ve had with Heroku has always been the lack of any easy way to do things pre-deploy, specifically packaging assets. My previous solution to this was to add in things I needed repackaged to a pre-commit git hook. 

The issue with this is that you don’t need to repackage on every commit and repackaging slows down your commits then. And secondarily git hooks aren’t stored in your repository, so every develop has to manually add in the hooks to their local clone.

The solution is simple though but one I just realized, deploy via a rake task. I haven’t seen this solution posted on Heroku docs or on any of the Stack Overflow questions with the same issue.

I choose to deploy via rake deploy:staging and rake deploy:production

In your Rails application create lib/tasks/deploy.rake

Then write a rake file that’s something like this. (This specific one runs jammit and then commits it’s changing before running the heroic deploy)


namespace :deploy do
  desc "Task to deploy app to Heroku"
  task :production do
    puts 'Preparing to deploy'
    puts 'Packaging Assets'
    system 'jammit'
    puts 'Committing Asset Packages'
    system "git commit public/assets/* -m'Asset Packages Rebuilt for Staging Deploy'"
    puts 'Deploying to Heroku'
    system("git push heroku master")
  end
end

You can also use the Heroku-Rails gem https://github.com/railsjedi/heroku-rails which adds before and after deploy hooks, but I felt like this was overkill for my needs.

reference: reddit needs help
Host Based SSL on Heroku with GoDaddy SSL Certificate

7/10/210

It took me several tries to get an SSL Certificate from GoDaddy to work on Heroku without scary warnings in IE or Firefox. I do not suggest using GoDaddy for anything. I only used it in this case as my client was using it. But I figure other people are in the same boat so hopefully this post can help out a few of you.

Contents

Further Reading - Heroku’s SSL Doc

Generate RSA Key and Certificate Signing Request (Tested on OS X 10.6, should work on any system with openssl)

openssl req -new -newkey rsa:2048 -nodes -out www.yourdomain.com.csr -keyout www.yourdomain.com.key

Ensure the common name is the domain and subdomain you want SSL on. (Example: www.yourdomain.com) and keep the password blank. Fill out the rest as it requests, it’s fine to leave things like the email blank.

Further reading - https://www.digicert.com/easy-csr/openssl.htm

Purchase and Download SSl Certificate from GoDaddy

Go here and follow through their checkout process http://www.godaddy.com/ssl/ssl-certificates.aspx?ci=8979

After that you have to go here https://mya.godaddy.com/Products/AccountList.aspx?ci=9038&Product=ssl and use the credit you just bought.

And then into here https://certs.godaddy.com/ccp/home.seam?cid=28267 to actually use the credit you just bought! GoDaddy has worked hard to make this process very confusing and hide the links to each part.

From here click “Request Certificate”, and paste in the Certificate Signing Request we generated early. You can print it out to terminal with

cat www.yourdomain.com.csr

Make sure you are requesting the specific subdomain you want the SSL for (normally you will want “www.yourdomain.com”).

Walk through their steps, once complete download your certificate for server type “other”. Unzip the files and move them into the same folder as the key we generated.

Combine the Certificate with the chain/intermediate certificate

GoDaddy gives you the Certificate and chain/intermediate certificate separately, we need to combine these before uploading to Heroku.

cat www.yourdomain.com.crt gd_bundle.crt > combined_www.yourdomain.com.pem

Setup and Upload to Heroku

Add the Host Based SSL to your application on Heroku. This one only costs $20 a month and displays no warnings on major browsers. Unfortunately you have to be using a subdomain, so while www.yourdomain.com will work, yourdomain.com won’t.

To add this type 

heroku addons:add ssl:hostname

And then be sure to change your DNS for the subdomain to point the the address Heroku emails you.

Ensure your certificate ends in .pem or IE7 (and I think IE8) will display the “There is a problem with this website’s security certificate.” warning.

From the folder with the keys

heroku ssl:add combined_www.yourdomain.com.pem www.yourdomain.com.key

Test!

Very important: Check to make sure SSL is working without warnings on every browser you plan to support. The warnings that browsers give out when they are unhappy with https page is very scary to users and results in lose of sales and confidence in your site.

Hope this helped you out!

-Eric Cranston

Launch!

Hello! We’re very excited to be launching our first startup. We’ve been working with startups for the last 4 years, but it’s just not the same as when it’s your own. 

Dead Simple Monitor started from simple personal desires. To have a Website Up Monitor that would call individuals as well as alert via SMS and email. At the time, none did. The alerts were limited and overly complicated in distribution. This evolved into formulating a pragmatic application for monitoring.

It began as a basic check for a status 200, and an alert if it’s not there. We added a lot of features and ideas, but then cut the extraneous ones realizing it needed to be simple and natural. Dead Simple Monitor has been sculpted down to the core of Website Up Monitoring. Our primary focus is on intuitive functionality rather than extraneous features.

We are committed to building the best Website Up Monitor for most website owners needs. If you have any suggestions to help us to our goal contact us at support@deadsimplemonitor.com.

Dead Simple Monitor Co-Founders:

- Eric Cranston, Candle Flynn