Deploying a Rails 3 Application Using Bundler and Capistrano

During the deployment of the Rails3 application in capistrano, I want my server to set stones using Gemfile.lock every time I deploy. And since my server doesn’t have rvm and that’s all .. All gems should be installed as system gems.

To install system stones, we need to sudo gem install anygem or for bunder, we need to give the sudo bundle install command inside our current directory of the capistrano deployment structure.

Each time I deploy, my deployment is broken down into the stone installation process. I need sudo bundle install to run. For this I need a deployment hook for capistrano. The pre-made ones, which are delivered by the packer airplane itself, do not work for me. My confusion boils down to these three questions.

  • When do I need to call the sudo bundle install command during the deployment process - I mean, after what is the capistrano task?

  • To run sudo commands using capistrano, what declarations should I specify in the cap file? Note. I have already included my public key as authorized keys on my server.

  • How should the package installation hook be set in the cap file?

Please, help.

+4
source share
3 answers

If you run bundle install --deployment , you do not need sudo access, since the gems must be installed in the vendor / package in the application, and not in the system itself.

+2
source

Adding require "bundler/capistrano" to your deploy.rb should work. He must declare a folder for installing gems that do not require sudo access, regardless of rvm.

Is this really not for you?

+5
source

I use this in my deploy.rb:

 require "bundler/capistrano" ... deploy recipe namespace :bundle do desc "Install bundles into application" task :install, :roles => [:app] do run "cd #{current_path} && LC_ALL='en_US.UTF-8' bundle install --deployment --without test" end end 

Then, after a normal deployment, I ran "cap bundle: install"

Note. Using UTF-8 to prevent problems with Ruby1.9 ASCII characters.

0
source

Source: https://habr.com/ru/post/1346039/


All Articles