Platform As A Service, By Examples

Bookmark and Share

About Platform as a Service

"Platform as a Service"란 클라우드 컴퓨팅 서비스 개념의 하나로, 개별 개발자나 소규모 회사에게 소프트웨어 개발/운영 플랫폼을 서비스 형태로 제동하는 것을 목표로 한다. 개발자는 자신의 응용소프트웨어를 운영하기 위하여 인프라를 구입하거나 소유하지 않는 대신, PaaS 제공자로부터 공간/자원을 할당받아 이용하게 된다.

A Kind of Magic

Google App Engine

Heroku

heroku is the easiest and best way to deploy all your Ruby applications
http://heroku.com/

  • Fast, stable, tons of new features
  • Over 32,000 applications running today
  • Full support and documentation
  • Free and commercial plans available

From Homepage

Introduction to Heroku

Heroku is the instant ruby platform. Deploy any ruby app instantly with a simple and familiar git push. Take advantage of advanced features like HTTP caching, memcached, rack middleware, and instant scaling built into every app. Never think about hosting or servers again.

Multi-Tenant

Heroku is a multi-tenant platform and hosting environment. Your app doesn’t need its own servers, slices, or clusters, and you’ll benefit from continuous platform improvements.

Fully Managed

Each element in this diagram represents a large pool of servers invisibly managed by Heroku. Because we control all the infrastructure and software layers, we can present a clean interface for deploying your code.

Curation

We actively curate each layer, ensuring you have the latest in software and best practices, and that it’s all stable and integrated smoothly.

Everything You Need

Together, these elements provide everything you need to run a modern, high-performance, scalable web app. Click around to understand the path of a request through the system.

Installation

Install required packages from apt repository.

$ sudo apt-get install ruby ruby-dev rubygems rails
$ sudo apt-get install make

Install heroku gem from gem repository.

sio4@sandbox:~$ export PATH="$PATH:/home/sio4/.gem/ruby/1.8/bin"
sio4@sandbox:~$ 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 json-1.1.9
Successfully installed heroku-1.2.1
2 gems installed
Installing ri documentation for json-1.1.9...
Installing ri documentation for heroku-1.2.1...
Installing RDoc documentation for json-1.1.9...
Installing RDoc documentation for heroku-1.2.1...
sio4@sandbox:~$

Setup Environment

Upload secure key.

sio4@sandbox:~$ heroku keys:add /home/sio4/.ssh/hosting.pub 
Uploading ssh public key /home/sio4/.ssh/hosting.pub
Enter your Heroku credentials.
Email: sio4@example.com
Password: 
Uploading ssh public key /home/sio4/.ssh/hosting.pub
sio4@sandbox:~$

refs: Installing the Heroku command-line tool

Create App

create/register app with specific name

sio4@sandbox:~/works$ heroku create appname
Created http://appname.heroku.com/ | git@heroku.com:appname.git

but,

sio4@sandbox:~/works$ git clone git@heroku.com:appname.git
Initialized empty Git repository in /home/sio4/works/appname/.git/
Warning: Permanently added the RSA host key for IP address '174.129.212.2' to the list of known hosts.
fatal: no matching remote head
sio4@sandbox:~/works$

Create Local git repository and make relationship

sio4@sandbox:~/works$ cd appname/
sio4@sandbox:~/works/appname$ git init
Initialized empty Git repository in /home/sio4/works/appname/.git/
sio4@sandbox:~/works/appname$ touch README
sio4@sandbox:~/works/appname$ git add README 
sio4@sandbox:~/works/appname$ git commit -m "initialize repository"
Created initial commit 3f3970d: initialize repository
 0 files changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 README
sio4@sandbox:~/works/appname$ git remote add heroku git@heroku.com:appname.git
sio4@sandbox:~/works/appname$ cat .git/config 
[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
[remote "heroku"]
    url = git@heroku.com:appname.git
    fetch = +refs/heads/*:refs/remotes/heroku/*
sio4@sandbox:~/works/appname$ git push heroku master
Counting objects: 3, done.
Writing objects: 100% (3/3), 211 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)

-----> Heroku receiving push
FAILED
 !     Heroku push rejected, no Rails or Rack app detected.

error: hooks/pre-receive exited with error code 1
To git@heroku.com:appname.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@heroku.com:appname.git'
sio4@sandbox:~/works/appname$

Oops! I need at least initialize rails before. ok, then try again.

sio4@sandbox:~/works$ rails appname
      create  
      create  app/controllers
      create  app/helpers
      ...
sio4@sandbox:~/works$ cd appname/
sio4@sandbox:~/works/appname$ git init
Initialized empty Git repository in /home/sio4/works/appname/.git/
sio4@sandbox:~/works/appname$ git add .
sio4@sandbox:~/works/appname$ git commit -m "initialize rails application with git."
Created initial commit 8ff89d1: initialize rails application with git.
 53 files changed, 8498 insertions(+), 0 deletions(-)
 create mode 100644 README
 create mode 100644 Rakefile
 create mode 100644 app/controllers/application.rb
 ...
sio4@sandbox:~/works/appname$ git remote add heroku git@heroku.com:appname.git
sio4@sandbox:~/works/appname$ cat .git/config
[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
[remote "heroku"]
    url = git@heroku.com:appname.git
    fetch = +refs/heads/*:refs/remotes/heroku/*
sio4@sandbox:~/works/appname$ git push heroku master
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://appname.heroku.com deployed to Heroku

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

OK, all done right!

refs: Creating Apps

Another way, more simple way

sio4@sandbox:~/works$ rails appname
      create  
      create  app/controllers
      create  app/helpers
      ...
sio4@sandbox:~/works$ cd appname/
sio4@sandbox:~/works/appname$ git init
Initialized empty Git repository in /home/sio4/works/appname/.git/
sio4@sandbox:~/works/appname$ git add .
sio4@sandbox:~/works/appname$ git commit -m "initialize rails application 'appname' for heroku."
Created initial commit 47a6494: initialize rails application 'appname' for heroku.
 53 files changed, 8498 insertions(+), 0 deletions(-)
 create mode 100644 README
 create mode 100644 Rakefile
 create mode 100644 app/controllers/application.rb
 ...
sio4@sandbox:~/works/appname$ heroku create appname
Created http://appname.heroku.com/ | git@heroku.com:appname.git
Git remote heroku added
sio4@sandbox:~/works/appname$ git push heroku master
Counting objects: 71, done.
Compressing objects: 100% (57/57), done.
Writing objects: 100% (71/71), 80.44 KiB, done.
Total 71 (delta 15), reused 0 (delta 0)

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

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

OK, done with only se7en command.

More about Heroku

http://heroku.com/
http://heroku.com/how
http://heroku.com/pricing
http://docs.heroku.com/
http://docs.heroku.com/technologies
http://docs.heroku.com/gems

Bookmark and Share


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