2015-10-06 24 views
0

所以我有一种情况,我们将我们的存储(git repo)环境迁移到不同的box.Let的调用这个stash_box。capistrano部署没有目标生产箱访问混帐框

现在,以前这是我部署到产品的过程。

我有一个安全的linux框,用于部署。让我们调用这个deploy_box。

我们调用目标prod服务器prod_box。

现在以前procuction箱不得不藏匿盒SSH访问(prod_box - > stash_box)

所以,当我从deploy_box &运行

cap prod_box deploy 

拉代码它曾经成功部署。

现在,有一个防火墙规则,没有 t允许prod_box与具有git回购的stash_box对话。

据我了解,卡皮斯特拉诺需要目标服务器&存储服务器之间的连接。

现在,deploy_box可以同时到达stash_box和prod_box两种方式。

有没有办法通过修改现有的capistrano脚本来实现生产部署?

这是我现有的deploy.rb文件:

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


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

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

set :scm,   :git 
set :repository, "ssh://[email protected]_box: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 

end 

namespace :custom do 

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

这是我prod_box.rb文件:

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

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

回答

1

只需使用一个不同的部署策略:

set :deploy_via, :copy 

现在源代码将在本地检出并上传到远程。你可以阅读更多有关here

编辑

对于Capistrano的V3,你将不得不使用这种gem,并指定:

set :scm, :gitcopy 
+0

,这不符合Capistrano的3个工作,不是? – Micheal

+0

@Micheal更新了我的答案capistrano 3. – Magnuss

+0

谢谢,我会试试。 capistrano 3删除了deploy_via复制方法是否有原因?是否存在与上述方法相关的一些缺陷 – Micheal