lundi 1 juin 2015

capistrano deployment unable to bundle install gem with no internet connection

I am deploying my application to a new server which has everything installed.

I am using the following capistrano deploy.rb:

require "capistrano/ext/multistage"
require "bundler/capistrano"

set :default_environment, {
    'ORACLE_HOME' => "/opt/oraclient/64/11.2.0.2/",
    'LD_LIBRARY_PATH' => "$ORACLE_HOME/lib:/usr/local/lib",
    'PATH' => "/opt/ruby/bin:$PATH:$ORACLE_HOME/bin"
}

SECURE_FILES = ['database.yml', 'ldap.yml', 'initializers/secret_token.rb']

set :application,   "myapp"
set :use_sudo,      false

set :scm,           :git
set :repository, "ssh://git@hostname:7999/web/myapp.git"
set :user, "webuser"
set :deploy_via, :remote_cache

after "deploy:update_code", "custom:create_symlinks", "custom:assets_precompile", "custom:miscellaneous"
after "deploy", "deploy:migrate"
after "deploy", "deploy:cleanup"

namespace :deploy do
  desc "Restarting mod_rails with restart.txt"
  task :restart, :roles => :app, :except => { :no_release => true } do
    run "touch #{current_path}/tmp/restart.txt"
  end

  [:start, :stop].each do |t|
    desc "#{t} task is a no-op with mod_rails"
    task t, :roles => :app do ; end
  end

  namespace :web do
    desc "Enable maintenance mode for apache"
    task :enable_maintenance, :role => :web do

      run "mkdir -p #{shared_path}/system"
      on_rollback { run "rm -f #{shared_path}/system/maintenance.html" }
      page = File.read('public/maintenance.html')
      put page, "#{shared_path}/system/maintenance.html", :mode => 0644
    end

    desc "Disable maintenance mode for apache"
    task :disable_maintenance, :role => :web do
      run "rm -f #{shared_path}/system/maintenance.html"
    end
  end
end

namespace :custom do
  desc "Creating config, bundler-GEMS symlinks"
  task :create_symlinks, :roles => :app do

    #Secure Configuration File Symlinks 
    SECURE_FILES.each do |link|
      fobj = "#{release_path}/config/#{link}"
      run <<-CMD
        if [ -e #{fobj} ]; then rm -f #{fobj}; fi;
        rm -f #{previous_release}/config/#{fobj};
        ln -s #{vormetric_path}/#{application}/#{link} #{fobj};
      CMD
    end

    #Bundler GEM Installation Symlink 
    shared_bundler_dir = File.join(shared_path, 'bundle')
    release_bundler_dir = File.join(current_release, 'vendor/bundle')
    run "ln -s #{shared_bundler_dir} #{release_bundler_dir}"
  end

  desc "Assets Pre-Compilation"
  task :assets_precompile, :roles => :app do
    run "cd #{current_release} && RAILS_ENV=#{rails_env} bundle exec rake assets:precompile"
  end

  desc "Miscellaneous Tasks"
  task :miscellaneous, :roles => :app do
    run "chmod -f +w #{current_release}/db/schema.rb"
  end
end

This is box-specific deploy script myhostname.rb:

server "myhostname", :app, :web, :db, :primary => true

set :deploy_to, "/opt/web/var/myapp"
set :rails_env, "customertest"
set :branch, "staging"

Now the remote box does not have access to internet, but I have all my gems stored under vendor/cache. So it should pick up from there.(vendor/cache has nokigiri under /myapp/current/vendor/cache on remote server)

When i run

cap deploy servername

, i get the following error:

 ** [out :: myhost] An error occurred while installing nokogiri (1.5.9), and Bundler cannot
 ** [out :: myhost] continue.
 ** [out :: myhost] Make sure that `gem install nokogiri -v '1.5.9'` succeeds before bundling.

My remote box where the code is supposed to be deployed has the following folders set up:

 /opt/web/var/myapp
 /opt/web/var/myapp/current(where all the code is cloned currently)
 /opt/web/var/myapp/releases
 /opt/web/var/myapp/shared

I am not sure how it i supposed to pick up and install the gem.

Aucun commentaire:

Enregistrer un commentaire