###Downloads
-
Begin by downloading and installing The Heroku Toolkit via MacOSX or Ubuntu. (The Toolkit includes Heroku Command Line utility, as well as git and Foreman.)
-
Install the Bundler gem for Ruby. ( Learn about Bundler )
$ gem install bundler
###Adding Files
- Create a new folder and ensure your folder is not git-enabled...
$ mkdir newfolder
$ cd newfolder/
$ git status
...which should return:
fatal: Not a git repository (or any of the parent directories): .git
- Create a gemfile document
$ touch Gemfile
Create a Config.ru file to enable RackUp operations. Add this line
$ touch config.ru
$ cat > config.ru
require './main.rb' run Sinatra::Application
[CTRL-D]
Foreman uses a text file named ‘Procfile’ in the root directory of your app to declare what processes need to run. Create a Procfile
$ touch Procfile
- Open Gemfile in your text editor. Specify the production gems that your application depends.
source 'https://rubygems.org'
gem 'sinatra'
gem 'pry'
gem 'sinatra-reloader'
- Bundle your gems
$ bundle
... which should return something like this:
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.
- Edit Procfile to run your main ruby file:
web: bundle exec ruby main.rb -p $PORT
###Deployment
- Now Login to Heroku and create a SSH Key
$ heroku login
Enter your Heroku credentials.
Email: [email protected]
Password:
Could not find an existing public key.
Would you like to generate one? [Yn]
Generating new SSH public key.
Uploading ssh public key /Users/adam/.ssh/id_rsa.pub
- Create a new web application
$ heroku create
Creating murmuring-galaxy-997... done, stack is cedar
http://murmuring-galaxy-997.herokuapp.com/ | [email protected]:murmuring-galaxy-997.git
Git remote heroku added
- Connect your local repository to the Heroku repository
$ heroku git:remote -a murmuring-galaxy-997
Git remote heroku added.
- Test using Foreman, if it doesn't run properly, fix bugs and then test again.
$ foreman start
16:39:04 web.1 | started with pid 30728
18:49:43 web.1 | [2013-03-12 18:49:43] INFO WEBrick 1.3.1
18:49:43 web.1 | [2013-03-12 18:49:43] INFO ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux]
18:49:43 web.1 | [2013-03-12 18:49:43] INFO WEBrick::HTTPServer#start: pid=30728 port=5000
- Push your code to Heroku
$ git add .
$ git commit -m "first deployment to heroku"
$ git push heroku master
- Check your status with logs
$ heroku logs