Skip to content

Instantly share code, notes, and snippets.

@markoa
Created March 15, 2011 11:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markoa/870606 to your computer and use it in GitHub Desktop.
Save markoa/870606 to your computer and use it in GitHub Desktop.
The snippet for config/deploy.rb to use Bundler.
# use this in a after "deploy:update_code" block
namespace :bundler do
task :create_symlink, :roles => :app do
shared_dir = File.join(shared_path, 'bundle')
release_dir = File.join(current_release, '.bundle')
run("mkdir -p #{shared_dir} && ln -s #{shared_dir} #{release_dir}")
end
task :bundle_new_release, :roles => :app do
bundler.create_symlink
shared_dir = File.join(shared_path, 'bundle')
run "cd #{release_path} && bundle install --path #{shared_dir} --without test development"
end
task :lock, :roles => :app do
run "cd #{current_release} && bundle lock;"
end
task :unlock, :roles => :app do
run "cd #{current_release} && bundle unlock;"
end
end
@kidbrax
Copy link

kidbrax commented Apr 12, 2011

Marko,
Which of these tasks will need to be run after each deployment?

@kidbrax
Copy link

kidbrax commented Apr 12, 2011

nevermind, I RTFM and figured that out. But a better question is when to lock and unlock. You lock after you do a bundle install and unlock only when you are changing your Gemfile and redeploying?

@markoa
Copy link
Author

markoa commented Apr 12, 2011

I don't ever do anything to Gemfile.lock - Bundler changes it itself when you do a bundle install and a newer version of something is available, or you add a new dependency to Gemfile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment