Heroku ã試ãã¦ã¿ã
Ruby On Rails ã® PaaS ã¨ãã¦æå㪠Heroku ã®ä½¿ãæ¹ã«ã¤ãã¦ã¾ã¨ãã¦ã¿ã¾ãã
åèæ å ±:
éçºç°å¢ã¨ãã¦ã¯ãDebian 6.0 ãç¨ãã¾ãã
å°ãHerokuã® ruby version 㯠1.9.2ã®æ¨¡æ§ãªã®ã§ãDebianããã±ã¼ã¸ã® ruby ã¯ä½¿ããã« rvm ã«ã¦ã¤ã³ã¹ãã¼ã«ãã ruby-1.9.2 ã使ç¨ãã¾ãã
rubyã®ã¤ã³ã¹ãã¼ã«(rvmã使ç¨)
$ bash < <(curl -sk https://rvm.beginrescueend.com/install/rvm)
$ vi ~/.bash_profile
(ä¸è¨ã追å ããrvmç°å¢ãæå¹ã«ãã)
-s "$HOME/.rvm/scripts/rvm" && . "$HOME/.rvm/scripts/rvm"
(ãã¹ãä¾)
$ rails generate scaffold User name:string id:integer
$ rake db:migrate
$ git -a -m "update db"
$ git push heroku master
$ heroku rake db:migrate
(readlineãopensslçãheroku ã§ä½¿ç¨ããããªrubyã©ã¤ãã©ãªã¯äºãçµã¿è¾¼ãã§ããã¾ã)
$ rvm pkg install readline
$ rvm pkg install openssl
$ rvm pkg install zlib
$ rvm install 1.9.2 --with-openssl-dir=$HOME/.rvm/usr \
--with-readline-dir=$HOME/.rvm/usr \
--with-zlib-dir=$HOME/.rvm/usr
$ rvm use 1.9.2 --default
Ruby on Rails(éçºç°å¢ã®æºå)
次ã«ãRuby on Railsãã¤ã³ã¹ãã¼ã«ãã¾ãã
$ gem install rails
$ bundle install
Heroku ãã¤ã³ã¹ãã¼ã«
次ã«ãherokuãµã¼ãã¹ã«ã¢ã¯ã»ã¹ããããã®ããã±ã¼ã¸(gem)ãã¤ã³ã¹ãã¼ã«ãã¾ãã
$ gem install heroku
ãã¹ãã¢ããªã®ä½æ
éçºç°å¢ã®æ§ç¯ãå®äºããã®ã§ã次㯠railsã¢ããªãä½æãã¾ãã
$ rails generate hello
$ rails server
(éçºç°å¢ã§ã¢ããªãèµ·åãããã¨ã確èª)
heroku ã« deploy
herokuã«ã¢ããªããããã¤ããã«ã¯ã以ä¸ã®æé ãè¸ã¿ã¾ãã
- railsã¢ããªãéçºç°å¢ã§ä½æ
- herokuå´ã®ã¢ããªã±ã¼ã·ã§ã³ãµã¼ããèµ·å(ååã®ã¿)
- gitãªãã¸ããªã«ã½ã¼ã¹ã³ã¼ããç»é²(ã¾ãã¯æ´æ°)
- git pushã³ãã³ããç¨ã㦠heroku ã«ã½ã¼ã¹ã³ã¼ãã転é
herokuå´ã®ã¢ããªã±ã¼ã·ã§ã³ãµã¼ããèµ·å
$ heroku create
herokuå´ã®ã¢ããªã±ã¼ã·ã§ã³ãµã¼ããèµ·åãã¾ãããµã¼ããèµ·åããã¨ãURLãçºè¡ããã¾ãã
åå㯠Emailã¢ãã¬ã¹åã³ãã¹ã¯ã¼ããè¦æ±ããã¾ãã®ã§ããµã¤ã³ã¢ããæã«ç»é²ããæ å ±ãå ¥åãã¾ãã
Enter your Heroku credentials.
Email: joe@example.com
Password:
Uploading ssh public key /Users/joe/.ssh/id_rsa.pub
Created http://high-sunrise-58.heroku.com/ | [email protected]:high-sunrise-58.git
Git remote heroku added
gitãªãã¸ããªã«ã½ã¼ã¹ã³ã¼ããç»é²
(railsã½ã¼ã¹ã³ã¼ãã® top ãã£ã¬ã¯ããªã«ã¦)
$ git init
$ git add .
$ git commit -m "Initial code"
git pushã³ãã³ããç¨ã㦠heroku ã«ã½ã¼ã¹ã³ã¼ãã転é
$ git push heroku master
ãã©ã¦ã¶ãéãã¦ã¢ããªã®åä½ã確èª
$ heroku open
heroku 管çWeb-UI
herokuã®webãµã¤ãã«ãã°ã¤ã³ããã¨ãä¸è¨ã®ãããªç®¡çç»é¢ã表示ãããã¨ãã§ãã¾ãã
heroku db:migrate 注æç¹
heroku 㧠db:migrate ããããã¨ããã¨ãrakeã³ãã³ããã¨ã©ã¼ã§åæ¢ãã¦ãã¾ãã¾ããRakefile ã® "require 'rake'" ã®æåã§ä»¥ä¸ã® requireæ ã追å ããã¨è¯ãããã§ãã
require 'rake/dsl_definition'
(ãã¹ãä¾)
$ rails generate User name:string id:integer
$ rake db:migrate
$ git add .
$ git commit -m "update db"
$ git push heroku master
$ heroku rake db:migrate