Author: Samson Ootoovak
This deploy procedure is typical for the the Sinatra skeleton on which our challenges are based. If you are on the EDA computers then the Heroku Toolbelt is already installed. If you are on your own computer then you have to install it first.
A note is that Heroku's free account locks you in to a specific public SSH key. This means if one person deploys to their Heroku account with a EDA computer that computer is affectivly locked to their account until they delete the computer's SSH key from their Heroku account (the SSH key gets automatically re-uploaded after each deploy). Long story short, if you can, it is likely just easier to deploy from a personal computer. If you can't then no worries, just try to remember to delete the SSH key from your Heroku account after you are done with the computer (you can ask me, Joshua, or a Ruby coach for help if you need it).
An example of an EDA challenge I deployed to Heroku:
- Signup for a free Heroku account.
- Make sure your Sinatra or Rails app is in the root directory.
- Put
heroku logininto your Terminal an run
You will see something like:
Enter your Heroku credentials.
Email:
Password (typing will be hidden):- Put in the email address and password you used to sign up to Heroku.
If you see
! Unable to connect to Heroku API, please check internet connectivity and try again.Then Heroku did not install correctly. Try to install the Heroku toolbelt again or call an instructor over.
- Then run
heroku create
You will see something like:
Creating still-thicket-3480... done, stack is cedar
http://still-thicket-3480.herokuapp.com/ | git@heroku.com:still-thicket-3480.git
Git remote heroku added- Then run
git push heroku my_branch:masterwheremy_branchis the local git branch you want to deploy.
You will then see soemthing like:
Initializing repository, done.
Counting objects: 382, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (300/300), done.
Writing objects: 100% (382/382), 7.98 MiB | 237.00 KiB/s, done.
Total 382 (delta 60), reused 307 (delta 40)
-----> Ruby app detected
-----> Compiling Ruby/Rack
-----> Using Ruby version: ruby-2.0.0
-----> Installing dependencies using 1.6.3
...And lot of other stuff. Keep an eye out for any error messages towards the end of the output.
- If you have any database migrations be sure to run
heroku run rake db:migrate - If you need to seed your database run
heroku run rake db:seed - Finally
heroku openshould open your deployed site in a browser. - Congratulations! You now have an app on the Internet!
heroku logs --tailwill show you logs. This helps find out what is going wrong if you app is not shwowing up in the browser.- Make sure the gems you need are not just in the "test" or "development" groups in you Gemfile. I had to move the
rspecgem out of thetestgroup for example to get the anagram challenge example solution to deploy.