Capistrano 㧠Bundler 1.0 ã使ã
ç¾å¨ãCapistrano 㧠Rails ã¢ããªã±ã¼ã·ã§ã³ foo ãããªã¢ã¼ããµã¼ãã® /var/rails/foo ã«é ç½®ãã¦ããã¨ä»®å®ãã¾ãã
ãã ããããã¾ã§ã¯ Bundler ã使ã£ã¦ããªãã¨ãã¾ãã
RubyGems ã®ã¢ãããã¼ãä½æ¥ãèªååãããããBundler 1.0 ãå°å ¥ãã¦ã¿ã¾ãããã
â» ãã®è¨äºã¯ Bundler 1.0.0.rc.1 ã«åºã¥ãã¦ãã¾ãã
ã¾ããdeploy.rb ã« deploy:bundle ã¿ã¹ã¯ã追å ãã¾ãã
namespace :deploy do
(çç¥)
desc "Run bundle install"
task :bundle do
run "cd #{release_path} && bundle install #{shared_path}/lib"
end
end
#{release_path} 㯠/var/rails/foo/current ã«ã#{shared_path}/lib 㯠/var/rails/foo/shared/lib ã«å±éããã¾ãã
è¦ããã«ãRails.root ã« cd ã㦠bundle install /var/rails/foo/shared/lib ã¨ããã³ãã³ããå®è¡ããã¨ããã¿ã¹ã¯ã§ãã
bundle install ãå¼æ°ç¡ãã§å®è¡ããã¨ãã·ã¹ãã å ¨ä½ã® gem ã¨ã㦠/usr/local/lib/ruby/gems/1.8/gems 辺ãã«ã¤ã³ã¹ãã¼ã«ããã¦ãã¾ãã¾ãã
è¤æ°ã® Rails ã¢ããªã±ã¼ã·ã§ã³ãåãã¦ãããµã¼ãã§ãããããã®ã¯ã¨ã¦ãå±éºã§ãã
ãã㧠foo ã®ããã® gem 㯠/var/rails/foo/shared/lib ã«éé¢ããããã§ãããã®ããæ¹ã¯ãBundler ã®ä½è Yehuda Katz ãæ¨å¥¨ãã¦ãã¾ãã
ç¶ãã¦ã次ã®ãããªã³ã¼ãã deploy.rb ã«è¿½å ãã¾ãã
after "deploy:update", :roles => :app do
deploy.bundle
end
ãã ããæ¢ã« after "deploy:update" ãå®ç¾©ããã¦ããå ´åã¯ããã®ä¸ã« deploy.bundle ã追å ãã¾ãã
ãã®ã³ã¼ãã¯ãdeploy:update ã¿ã¹ã¯ãå®è¡ããç´å¾ã«å®è¡ããã¾ãã
ãããã£ã¦ãæ°ããã¢ããªã±ã¼ã·ã§ã³ããªã¢ã¼ããµã¼ãã«é ç½®ãããã³ã«ãRails.root 㧠bundle install ãå®è¡ãããå¤ããªã£ã gem ãæ´æ°ããã¾ãã
ããã¯ã便å©ã§ããï¼
ãã¦ãã²ã¨ã¤åä»ãªåé¡ãããã¾ãã
Bundler 㯠Gemfile ã«è¨è¿°ããã gem ãåã«ã¤ã³ã¹ãã¼ã«ãã¦ããã ããªã®ã§ãã¤ã³ã¹ãã¼ã«æã«ãªãã·ã§ã³ãå¿ è¦ãªå ´åããrubygems.org ãããã¦ã³ãã¼ãã§ããªãå ´åã¯ä½¿ãã¾ããã
ä¾ãã°ãä» foo ã¢ããªã±ã¼ã·ã§ã³ã bar ã¨ããæ¶ç©ºã® gem ãå¿ è¦ã¨ãã¦ãããããã®ããã±ã¼ã¸ã¯ rubygems.org ã«ã¯ãªãããã§ã«ãã¦ã³ãã¼ããã¦ãã ~/src/bar-1.2.3/bar-1.2.3.gem ãã¤ã³ã¹ãã¼ã«ããªãã¦ã¯ãªããªããã¨ããç¶æ³ãæ³å®ãã¾ãã
ããã§ãbundle install /var/rails/foo/shared/lib ãå®è¡ãã¦ãã次ã®ãããªã¨ã©ã¼ãåºã¦æ¢ã¾ã£ã¦ãã¾ãã§ãããã
Could not find gem 'bar (>= 0, runtime)' in any of the gem sources.
ãã®ãããªã¨ãã¯ãgem ã³ãã³ãã§ããããã /var/rails/foo/shared/lib ã« bar ãã¤ã³ã¹ãã¼ã«ããã°OKã§ãã
$ gem install ~/src/bar-1.2.3/bar-1.2.3.gem -i /var/rails/foo/shared/lib/ruby/1.8
æ«å°¾ã® /ruby/1.8 ãå¿ããªããã¨ï¼
ãªããroot 権éã§ã·ã¹ãã å ¨ä½ã« bar ãã¤ã³ã¹ãã¼ã«ãã¦ãã¾ãã¨ããæ¹æ³ã¯ãã¡ã§ãã
ç¹å®ã®ãã£ã¬ã¯ããªã«å¯¾ã㦠bundle install ããå ´åãã·ã¹ãã å ¨ä½ã® gem ã¯ç¡è¦ããã¾ãã
[åèè³æ]
- http://yehudakatz.com/2010/07/26/whats-new-in-bundler-1-0-0-rc-1/
- http://d.hatena.ne.jp/mirakui/20100703/1278165723
- http://blog.nicolasblanco.fr/2010/07/30/capistrano-task-for-bundler-1-0/
[UPDATE]
2010-08-09ã®コミットã«ãããèªå㧠deploy:bundle ã¿ã¹ã¯ãæ¸ãå¿
è¦ã¯ãªããªãã¾ãããåã«ãdeploy.rb ã®ä¸ã§
ã¨æ¸ãã ãã§ãdeploy:update ã®å¾ã§ deploy install ã³ãã³ããèªåçã«å®è¡ãããããã«ãªãã¾ãã
require 'bundler/capistrano'
ãªãããã®æ¹æ³ã使ãå ´åãããã©ã«ã㧠#{shared_path}/bundle ã« gems ãã¤ã³ã¹ãã¼ã«ããã¾ããã¤ã³ã¹ãã¼ã«å ãå¤æ´ãããå ´åã¯ãdeploy.rb ã®ä¸ã§
ã®ããã«æ¸ãã¦ãã ããã
set :bundle_dir, "#{shared_path}/lib"