Heroku Part 2

Bookmark and Share

Heroku Once More…

This is Platform-as-a-Service Mini-special of Heroku.com.

Prepare Development Environment

Most of all, we need to prepare some development software for it, including ruby, rails and git. heroku is a PaaS service for Ruby on Rails developers and users. It only support RoR applications. so, we need:

  • Install Ruby and Rails for application development
  • Install git for source code deployment.
  • Install some additional applications to solve dependency.

Install Related Softwares

Check current installation:

sio4@snow-white:~/works$ LANG= dpkg -l ruby ruby-dev rubygems rails
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Cfg-files/Unpacked/Failed-cfg/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad)
||/ Name           Version        Description
+++-==============-==============-============================================
ii  rails          2.1.0-6        MVC ruby based framework geared for web appl
ii  ruby           4.2            An interpreter of object-oriented scripting 
un  rubygems       <none>         (no description available)
No packages found matching ruby-dev.
sio4@snow-white:~/works$

Install ruby, rails and related tools.

sio4@snow-white:~/works$ sudo apt-get install ruby ruby-dev rubygems rails make
Reading package lists... Done
Building dependency tree       
Reading state information... Done
ruby is already the newest version.
ruby set to manually installed.
rails is already the newest version.
make is already the newest version.
The following extra packages will be installed:
  ruby1.8-dev
The following NEW packages will be installed:
  ruby-dev ruby1.8-dev rubygems
0 upgraded, 3 newly installed, 0 to remove and 1 not upgraded.
Need to get 584kB of archives.
After this operation, 1774kB of additional disk space will be used.
Do you want to continue [Y/n]? 
Get:1 http://kr.archive.ubuntu.com jaunty-updates/main ruby1.8-dev 1.8.7.72-3ubuntu0.1 [576kB]
Get:2 http://kr.archive.ubuntu.com jaunty/main ruby-dev 4.2 [5114B]
Get:3 http://kr.archive.ubuntu.com jaunty/universe rubygems 1.3.1-1 [2712B]
Fetched 584kB in 0s (2683kB/s)  
Selecting previously deselected package ruby1.8-dev.
(Reading database ... 140342 files and directories currently installed.)
Unpacking ruby1.8-dev (from .../ruby1.8-dev_1.8.7.72-3ubuntu0.1_i386.deb) ...
Selecting previously deselected package ruby-dev.
Unpacking ruby-dev (from .../archives/ruby-dev_4.2_all.deb) ...
Selecting previously deselected package rubygems.
Unpacking rubygems (from .../rubygems_1.3.1-1_all.deb) ...
Setting up ruby1.8-dev (1.8.7.72-3ubuntu0.1) ...
Setting up ruby-dev (4.2) ...
Setting up rubygems (1.3.1-1) ...
sio4@snow-white:~/works$

And heroku gem:

sio4@snow-white:~/works$ export PATH="$PATH:/home/sio4/.gem/ruby/1.8/bin"
sio4@snow-white:~/works$ gem install heroku
WARNING:  Installing to ~/.gem since /var/lib/gems/1.8 and
      /var/lib/gems/1.8/bin aren't both writable.
Building native extensions.  This could take a while...
Successfully installed rest-client-1.0.3
Successfully installed rake-0.8.7
Successfully installed configuration-1.1.0
Successfully installed launchy-0.3.3
Successfully installed json-1.1.9
Successfully installed heroku-1.2.2
6 gems installed
Installing ri documentation for rest-client-1.0.3...
Installing ri documentation for rake-0.8.7...
Installing ri documentation for configuration-1.1.0...
Installing ri documentation for launchy-0.3.3...
Installing ri documentation for json-1.1.9...
Installing ri documentation for heroku-1.2.2...
Installing RDoc documentation for rest-client-1.0.3...
Installing RDoc documentation for rake-0.8.7...
Installing RDoc documentation for configuration-1.1.0...
Installing RDoc documentation for launchy-0.3.3...
Installing RDoc documentation for json-1.1.9...
Installing RDoc documentation for heroku-1.2.2...
sio4@snow-white:~/works$

Install git if not installed:

sio4@snow-white:~/works/scout$ sudo apt-get install git-core
[sudo] password for sio4: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  libdigest-sha1-perl liberror-perl
Suggested packages:
  git-doc git-arch git-cvs git-svn git-email git-daemon-run git-gui gitk
  gitweb
The following NEW packages will be installed:
  git-core libdigest-sha1-perl liberror-perl
0 upgraded, 3 newly installed, 0 to remove and 1 not upgraded.
Need to get 4371kB of archives.
After this operation, 9208kB of additional disk space will be used.
Do you want to continue [Y/n]? 
Get:1 http://kr.archive.ubuntu.com jaunty/main liberror-perl 0.17-1 [23.8kB]
Get:2 http://kr.archive.ubuntu.com jaunty/main libdigest-sha1-perl 2.11-2build2 [25.4kB]
Get:3 http://kr.archive.ubuntu.com jaunty/main git-core 1:1.6.0.4-1ubuntu2 [4322kB]
Fetched 4371kB in 0s (5600kB/s)    
Selecting previously deselected package liberror-perl.
(Reading database ... 140380 files and directories currently installed.)
Unpacking liberror-perl (from .../liberror-perl_0.17-1_all.deb) ...
Selecting previously deselected package libdigest-sha1-perl.
Unpacking libdigest-sha1-perl (from .../libdigest-sha1-perl_2.11-2build2_i386.deb) ...
Selecting previously deselected package git-core.
Unpacking git-core (from .../git-core_1%3a1.6.0.4-1ubuntu2_i386.deb) ...
Processing triggers for man-db ...
Setting up liberror-perl (0.17-1) ...
Setting up libdigest-sha1-perl (2.11-2build2) ...
Setting up git-core (1:1.6.0.4-1ubuntu2) ...
sio4@snow-white:~/works/scout$

OK, all done.

Setup Working Environment

Upload and register public key to identifying me:

sio4@snow-white:~/works$ heroku keys:add ~/.ssh/hosting.pub 
Uploading ssh public key /home/sio4/.ssh/hosting.pub
Enter your Heroku credentials.
Email: scinix@example.com
Password: 
Uploading ssh public key /home/sio4/.ssh/hosting.pub
Contents already exists. Please use one ssh key per Heroku account
sio4@snow-white:~/works$

Oops! yes, I have one more account on it. sorry:-)

sio4@snow-white:~/works$ heroku keys:add ~/.ssh/heroku.pub 
Uploading ssh public key /home/sio4/.ssh/heroku.pub
Enter your Heroku credentials.
Email: scinix@example.com
Password: 
Uploading ssh public key /home/sio4/.ssh/heroku.pub
sio4@snow-white:~/works$

Yes, Now we can start!

Start New Project

Next step is create and deploy new application.

Create New Application called 'scout'.

sio4@snow-white:~/works$ rails scout
      create  
      create  app/controllers
      create  app/helpers
      create  app/models
      create  app/views/layouts
      create  config/environments
      create  config/initializers
      create  db
      create  doc
      create  lib
      create  lib/tasks
      create  log
      create  public/images
      create  public/javascripts
      create  public/stylesheets
      create  script/performance
      create  script/process
      create  test/fixtures
      create  test/functional
      create  test/integration
      create  test/unit
      create  vendor
      create  vendor/plugins
      create  tmp/sessions
      create  tmp/sockets
      create  tmp/cache
      create  tmp/pids
      create  Rakefile
      create  README
      create  app/controllers/application.rb
      create  app/helpers/application_helper.rb
      create  test/test_helper.rb
      create  config/database.yml
      create  config/routes.rb
      create  config/initializers/inflections.rb
      create  config/initializers/mime_types.rb
      create  config/initializers/new_rails_defaults.rb
      create  config/boot.rb
      create  config/environment.rb
      create  config/environments/production.rb
      create  config/environments/development.rb
      create  config/environments/test.rb
      create  script/about
      create  script/console
      create  script/dbconsole
      create  script/destroy
      create  script/generate
      create  script/performance/benchmarker
      create  script/performance/profiler
      create  script/performance/request
      create  script/process/reaper
      create  script/process/spawner
      create  script/process/inspector
      create  script/runner
      create  script/server
      create  script/plugin
      create  public/dispatch.rb
      create  public/dispatch.cgi
      create  public/dispatch.fcgi
      create  public/404.html
      create  public/422.html
      create  public/500.html
      create  public/index.html
      create  public/favicon.ico
      create  public/robots.txt
      create  public/images/rails.png
      create  public/javascripts/prototype.js
      create  public/javascripts/effects.js
      create  public/javascripts/dragdrop.js
      create  public/javascripts/controls.js
      create  public/javascripts/application.js
      create  doc/README_FOR_APP
      create  log/server.log
      create  log/production.log
      create  log/development.log
      create  log/test.log
sio4@snow-white:~/works$

Initiate git repository:

sio4@snow-white:~/works$ cd scout/
sio4@snow-white:~/works/scout$ git init
Initialized empty Git repository in /home/sio4/works/scout/.git/
sio4@snow-white:~/works/scout$ git add .
sio4@snow-white:~/works/scout$ git commit -m "initiate new application 'scout'." 
Created initial commit 6aedee9: initiate new application 'scout'.
 53 files changed, 8498 insertions(+), 0 deletions(-)
 create mode 100644 README
 create mode 100644 Rakefile
 create mode 100644 app/controllers/application.rb
 create mode 100644 app/helpers/application_helper.rb
 create mode 100644 config/boot.rb
 create mode 100644 config/database.yml
 create mode 100644 config/environment.rb
 create mode 100644 config/environments/development.rb
 create mode 100644 config/environments/production.rb
 create mode 100644 config/environments/test.rb
 create mode 100644 config/initializers/inflections.rb
 create mode 100644 config/initializers/mime_types.rb
 create mode 100644 config/initializers/new_rails_defaults.rb
 create mode 100644 config/routes.rb
 create mode 100644 doc/README_FOR_APP
 create mode 120000 doc/api
 create mode 100644 log/development.log
 create mode 100644 log/production.log
 create mode 100644 log/server.log
 create mode 100644 log/test.log
 create mode 100644 public/404.html
 create mode 100644 public/422.html
 create mode 100644 public/500.html
 create mode 100755 public/dispatch.cgi
 create mode 100755 public/dispatch.fcgi
 create mode 100755 public/dispatch.rb
 create mode 100644 public/favicon.ico
 create mode 100644 public/images/rails.png
 create mode 100644 public/index.html
 create mode 100644 public/javascripts/application.js
 create mode 100644 public/javascripts/controls.js
 create mode 100644 public/javascripts/dragdrop.js
 create mode 100644 public/javascripts/effects.js
 create mode 100644 public/javascripts/prototype.js
 create mode 100644 public/robots.txt
 create mode 100755 script/about
 create mode 100755 script/console
 create mode 100755 script/dbconsole
 create mode 100755 script/destroy
 create mode 100755 script/generate
 create mode 100755 script/performance/benchmarker
 create mode 100755 script/performance/profiler
 create mode 100755 script/performance/request
 create mode 100755 script/plugin
 create mode 100755 script/process/inspector
 create mode 100755 script/process/reaper
 create mode 100755 script/process/spawner
 create mode 100755 script/runner
 create mode 100755 script/server
 create mode 100644 test/test_helper.rb
 create mode 120000 vendor/actionmailer
 create mode 120000 vendor/actionpack
 create mode 120000 vendor/activemodel
 create mode 120000 vendor/activerecord
 create mode 120000 vendor/activeresource
 create mode 120000 vendor/activesupport
 create mode 120000 vendor/rails
 create mode 120000 vendor/railties
sio4@snow-white:~/works/scout$

Create Application on Heroku.com

sio4@snow-white:~/works/scout$ heroku create scout
Created http://scout.heroku.com/ | git@heroku.com:scout.git
Git remote heroku added
sio4@snow-white:~/works/scout$

OK, Now deploy it!

sio4@snow-white:~/works/scout$ git push heroku master
Warning: Permanently added the RSA host key for IP address '75.101.163.44' to the list of known hosts.
Counting objects: 71, done.
Compressing objects: 100% (57/57), done.
Writing objects: 100% (71/71), 80.43 KiB, done.
Total 71 (delta 15), reused 0 (delta 0)

-----> Heroku receiving push
-----> Rails app detected
       Compiled slug size is 80K
-----> Launching......... done
       http://scout.heroku.com deployed to Heroku

To git@heroku.com:scout.git
 * [new branch]      master -> master
sio4@snow-white:~/works/scout$

Just for test,

sio4@snow-white:~/works/scout$ cd ../test
sio4@snow-white:~/works/test$ git clone git@heroku.com:scout.git 
Initialized empty Git repository in /home/sio4/works/test/scout/.git/
remote: Counting objects: 71, done.
remote: Compressing objects: 100% (57/57), done.
remote: Total 71 (delta 15), reused 0 (delta 0)
Receiving objects: 100% (71/71), 80.16 KiB | 62 KiB/s, done.
Resolving deltas: 100% (15/15), done.
sio4@snow-white:~/works/test$

Bootstrapping and Open!

sio4@snow-white:~/works/scout$ heroku rake db:migrate
(in /disk1/home/slugs/71264_6aedee9_d564/mnt)
sio4@snow-white:~/works/scout$ heroku open
Opening http://scout.heroku.com/
sio4@snow-white:~/works/scout$

Nice!

Bookmark and Share


따로 명시하지 않는 한에서 이 사이트의 모든 콘텐츠는 다음의 라이선스를 따릅니다: Creative Commons Attribution-NonCommercial 3.0 License