Ruby Intro

SENG2021

Deploying With Heroku

Heroku is a pioneer in what we now call Platform-As-A-Service. It’s a little on the expensive side to scale on it, but its great for developing with as there is a freebie tier and its service makes deploying to the internet a breeze. Be aware however that if you need a database, PostgreSQL is your only option.

The newcomer in town is Appfog. They’re a lot cheaper than Heroku and supports MySQL in addition to PostgreSQL, but I haven’t had the chance to check them out yet.

Step 1

Sign up to Heroku

Step 2

Install the Heroku Toolbelt

Step 3

In the root folder of your application, type in the following commands

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# Initialize a git repository
git init

# Login to heroku (enter your username and password as prompted, generate ssh key if required)
heroku login

# Create a new app on heroku
# Make note of the output of this command
# The http url is where your application will be available - http://<app name>.heroku.com
# The git url is where you will be deploying the application to - git://heroku.com:<app name>.git
# The last line should say 'Git remote heroku added'
# If it doesn't, do 'heroku git:remote -a <app name>'
heroku create

# Add everything to git staging
git add .

# Commit the repository
git commit -m "initial commit"

# Push to Heroku for the first time
git push heroku master

# Ensure that only 1 web dyno will be running
heroku ps:scale web=1

Step 4

Your app should now be available in the http url mentioned in step 3. If there are any problems, you can watch your application’s live logging by using heroku logs -t. As usual, google your issues :) There are some relevant links to documentation below too.

  1. Heroku Signup
  2. Heroku Toolbelt
  3. Heroku Quickstart
  4. Heroku Rails4
  5. Heroku Rails3
  6. Heroku Billing
  7. Appfog Pricing
  8. Demo on Heroku