我在将rails应用程序部署到Digital Ocean时遇到问题 . 该应用程序使用Rails 5,ruby 2.4.0,capistrano和乘客 . 我试图通过SSH将bitbucket中的私有存储库连接到数字海洋,这可能是我的问题 .
这是我的deploy.rb
set :application, 'APP_NAME'
set :repo_url, 'git@bitbucket.org:USERNAME/APP_NAME.git'
set :user, "deploy"
set "stages", %w(production staging)
set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system')
namespace :deploy do
after :restart, :clear_cache do
on roles(:web), in: :groups, limit: 3, wait: 10 do
# Here we can do anything such as:
# within release_path do
# execute :rake, 'cache:clear'
# end
end
end
end
这是我的deploy / production.rb文件:
role :app, %w{deploy@ADDRESS}
role :web, %w{deploy@ADDRESS}
role :db, %w{deploy@ADDRESS}, :primary => true
set :branch, "master"
set :rails_env, "staging"
set :deploy_to, "var/www/APP_NAME_production"
我一直在关注这个tutorial on how to setup a rails app on digital ocean .
我可以完成一个cap staging deploy:check但是在运行cap staging deploy时遇到以下错误:
fatal: destination path 'var/www/APP_NAME/repo' already exists and is not an empty directory.
...
SSHKit::Command::Failed: git exit status: 128
...
任何帮助将不胜感激!
更新:宝石 -
gem 'rails', '~> 5.0.0', '>= 5.0.0.1'
ruby '2.4.0'
group :development do
# Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
gem 'web-console'
gem 'listen', '~> 3.0.5'
...
gem 'capistrano', '~>3.4.0'
gem 'capistrano-ssh-doctor', '~> 1.0'
gem 'capistrano-rails', '~>1.1'
gem 'capistrano-passenger'
end
Capfile:
# Load DSL and set up stages
require 'capistrano/setup'
require 'capistrano/ssh_doctor'
# Include default deployment tasks
require 'capistrano/deploy'
# Include tasks from other gems included in your Gemfile
#
# For documentation on these, see for example:
#
# https://github.com/capistrano/rvm
# https://github.com/capistrano/rbenv
# https://github.com/capistrano/chruby
# https://github.com/capistrano/bundler
# https://github.com/capistrano/rails
# https://github.com/capistrano/passenger
#
# require 'capistrano/rvm'
# require 'capistrano/rbenv'
# require 'capistrano/chruby'
require 'capistrano/bundler'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'
require 'capistrano/passenger'
# Load custom tasks from `lib/capistrano/tasks` if you have any defined
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
谢谢!