Первый раз пытаюсь развернуть приложение на своем домашнем сервере ubuntu server 14, установленным в VirtualBox`е. Капистрано первый раз начал прощупывать вчера. Кое-что даже получилось). Но тем не менее деплой не проходит. Беру чистое приложение rails (на локальном компе rails s стартует и показывает welcome). Пытаюсь его задеплоить. Вижу ошибку assets:precompile. Вообще можно ли его отключить, нужен ли он, можно ли его сделать на локальном компьютере, где можно подробнее почитать про него про этот ассетс:прекомпиле. На рабочем проекте тоже выдает ошибку (не помню какую), поэтому решил сначала взять чистый проект, а потом мучить рабочий. Выкладываю конфиги:
Gemfile:
source 'https://rubygems.org'
gem 'rails', '4.2.1'
gem 'sass-rails', '~> 5.0'
group :development do
gem 'sqlite3'
gem 'capistrano', '~> 3.4.0'
gem 'capistrano-rvm', '~> 0.1.1'
gem 'capistrano-bundler', '~> 1.1.3'
gem 'capistrano-rails', '~> 1.1.2'
end
group :production do
gem 'pg', '0.15.1'
gem 'passenger'
gem 'rack', '~> 1.6.1'
end
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
Capfile:
require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/rvm'
require 'capistrano/bundler'
require 'capistrano/rails'
Dir.glob('lib/capistrano/tasks/*.rb').each { |r| import r }
config/deploy.rb
lock '3.4.0'
set :application, 'myapp'
set :deploy_to, "/var/www/#{fetch(:application)}"
set :scm, :git
set :repo_url, 'ssh://deployer@127.0.0.1/var/www/myapp.git'
set :deploy_via, :remote_cache
set :branch, 'master'
set :rails_env, 'production'
set :rvm_custom_path, '/usr/share/rvm'
set :linked_files, %w{config/secrets.yml config/database.yml}
set :linked_dirs, %w{public/upload}
set :format, :pretty
set :pty, false
set :log_level, :info
set :rvm_ruby_string, :local # use the same ruby as used locally for deployment
namespace :deploy do
after :finishing, 'nginx:restart'
after :finishing, :cleanup
end
config/deploy/production.rb
server '192.168.1.106', user: 'deployer', roles: %w{web app}
lib/capistrano/tasks/nginx.rb
namespace :nginx do
desc 'Создание симлинка в /etc/nginx/conf.d на nginx.conf приложения'
task :append_config do
on roles :all do
sudo :ln, "-fs #{shared_path}/config/nginx.conf /etc/nginx/conf.d/#{fetch(:application)}.conf"
end
end
desc 'Релоад nginx'
task :reload do
on roles :all do
sudo :service, :nginx, :reload
end
end
desc 'Рестарт nginx'
task :restart do
on roles :all do
sudo :service, :nginx, :restart
end
end
after :append_config, :restart
end
lib/capistrano/tasks/setup.rb
namespace :setup do
desc 'Загрузка конфигурационных файлов на удаленный сервер'
task :upload_config do
on roles :all do
execute :mkdir, "-p #{shared_path}"
['shared/config'].each do |f|
upload!(f, shared_path, recursive: true)
end
end
end
after :upload_config, 'nginx:append_config'
end
вывод cap production deploy:
......
/var/www/myapp/shared/bundle --without development test --deployment --quiet
as deployer@192.168.1.106
INFO [bc0b956a] Finished in 15.350 seconds with exit status 0 (successful).
INFO [dd83e0ad] Running /usr/share/rvm/bin/rvm default do bundle exec rake asset
s:precompile as deployer@192.168.1.106
(Backtrace restricted to imported tasks)
cap aborted!
Сама ошибка:
SSHKit::Runner::ExecuteError: Exception while executing as deployer@192.168.1.10
6: rake exit status: 1
rake stdout: Nothing written
rake stderr: rake aborted!
LoadError: cannot load such file -- nokogiri
/var/www/myapp/shared/bundle/ruby/2.1.0/gems/loofah-2.0.3/lib/loofah.rb:3:in
`require'
/var/www/myapp/shared/bundle/ruby/2.1.0/gems/loofah-2.0.3/lib/loofah.rb:3:in
`<top (required)>'
/var/www/myapp/shared/bundle/ruby/2.1.0/gems/rails-html-sanitizer-1.0.2/lib/
rails-html-sanitizer.rb:2:in `require'
/var/www/myapp/shared/bundle/ruby/2.1.0/gems/rails-html-sanitizer-1.0.2/lib/
rails-html-sanitizer.rb:2:in `<top (required)>'
/var/www/myapp/shared/bundle/ruby/2.1.0/gems/actionview-4.2.1/lib/action_vie
w/helpers/sanitize_helper.rb:3:in `require'
/var/www/myapp/shared/bundle/ruby/2.1.0/gems/actionview-4.2.1/lib/action_vie
w/helpers/sanitize_helper.rb:3:in `<top (required)>'
/var/www/myapp/shared/bundle/ruby/2.1.0/gems/actionview-4.2.1/lib/action_vie
w/helpers/text_helper.rb:32:in `<module:TextHelper>'
/var/www/myapp/shared/bundle/ruby/2.1.0/gems/actionview-4.2.1/lib/action_vie
w/helpers/text_helper.rb:29:in `<module:Helpers>'
/var/www/myapp/shared/bundle/ruby/2.1.0/gems/actionview-4.2.1/lib/action_vie
w/helpers/text_helper.rb:6:in `<module:ActionView>'
/var/www/myapp/shared/bundle/ruby/2.1.0/gems/actionview-4.2.1/lib/action_vie
w/helpers/text_helper.rb:4:in `<top (required)>'
/var/www/myapp/shared/bundle/ruby/2.1.0/gems/actionview-4.2.1/lib/action_vie
w/helpers/form_tag_helper.rb:18:in `<module:FormTagHelper>'
/var/www/myapp/shared/bundle/ruby/2.1.0/gems/actionview-4.2.1/lib/action_vie
w/helpers/form_tag_helper.rb:14:in `<module:Helpers>'
/var/www/myapp/shared/bundle/ruby/2.1.0/gems/actionview-4.2.1/lib/action_vie
w/helpers/form_tag_helper.rb:8:in `<module:ActionView>'
/var/www/myapp/shared/bundle/ruby/2.1.0/gems/actionview-4.2.1/lib/action_vie
w/helpers/form_tag_helper.rb:6:in `<top (required)>'
/var/www/myapp/shared/bundle/ruby/2.1.0/gems/actionview-4.2.1/lib/action_vie
w/helpers/form_helper.rb:4:in `require'
/var/www/myapp/shared/bundle/ruby/2.1.0/gems/actionview-4.2.1/lib/action_vie
w/helpers/form_helper.rb:4:in `<top (required)>'
/var/www/myapp/shared/bundle/ruby/2.1.0/gems/actionview-4.2.1/lib/action_vie
w/helpers.rb:50:in `<module:Helpers>'
/var/www/myapp/shared/bundle/ruby/2.1.0/gems/actionview-4.2.1/lib/action_vie
w/helpers.rb:4:in `<module:ActionView>'
/var/www/myapp/shared/bundle/ruby/2.1.0/gems/actionview-4.2.1/lib/action_vie
w/helpers.rb:3:in `<top (required)>'
/var/www/myapp/shared/bundle/ruby/2.1.0/gems/sprockets-rails-2.3.2/lib/sproc
kets/rails/legacy_asset_tag_helper.rb:7:in `<module:LegacyAssetTagHelper>'
/var/www/myapp/shared/bundle/ruby/2.1.0/gems/sprockets-rails-2.3.2/lib/sproc
kets/rails/legacy_asset_tag_helper.rb:6:in `<module:Rails>'
/var/www/myapp/shared/bundle/ruby/2.1.0/gems/sprockets-rails-2.3.2/lib/sproc
kets/rails/legacy_asset_tag_helper.rb:4:in `<module:Sprockets>'
/var/www/myapp/shared/bundle/ruby/2.1.0/gems/sprockets-rails-2.3.2/lib/sproc
kets/rails/legacy_asset_tag_helper.rb:3:in `<top (required)>'
/var/www/myapp/shared/bundle/ruby/2.1.0/gems/sprockets-rails-2.3.2/lib/sproc
kets/rails/helper.rb:45:in `require'
/var/www/myapp/shared/bundle/ruby/2.1.0/gems/sprockets-rails-2.3.2/lib/sproc
kets/rails/helper.rb:45:in `<module:Helper>'
/var/www/myapp/shared/bundle/ruby/2.1.0/gems/sprockets-rails-2.3.2/lib/sproc
kets/rails/helper.rb:7:in `<module:Rails>'
/var/www/myapp/shared/bundle/ruby/2.1.0/gems/sprockets-rails-2.3.2/lib/sproc
kets/rails/helper.rb:6:in `<module:Sprockets>'
/var/www/myapp/shared/bundle/ruby/2.1.0/gems/sprockets-rails-2.3.2/lib/sproc
kets/rails/helper.rb:5:in `<top (required)>'
/var/www/myapp/shared/bundle/ruby/2.1.0/gems/sprockets-rails-2.3.2/lib/sproc
kets/railtie.rb:6:in `require'
/var/www/myapp/shared/bundle/ruby/2.1.0/gems/sprockets-rails-2.3.2/lib/sproc
kets/railtie.rb:6:in `<top (required)>'
/var/www/myapp/shared/bundle/ruby/2.1.0/gems/sass-rails-5.0.3/lib/sass/rails
/railtie.rb:3:in `require'
/var/www/myapp/shared/bundle/ruby/2.1.0/gems/sass-rails-5.0.3/lib/sass/rails
/railtie.rb:3:in `<top (required)>'
/var/www/myapp/shared/bundle/ruby/2.1.0/gems/sass-rails-5.0.3/lib/sass/rails
.rb:11:in `require'
/var/www/myapp/shared/bundle/ruby/2.1.0/gems/sass-rails-5.0.3/lib/sass/rails
.rb:11:in `<top (required)>'
/var/www/myapp/shared/bundle/ruby/2.1.0/gems/sass-rails-5.0.3/lib/sass-rails
.rb:1:in `require'
/var/www/myapp/shared/bundle/ruby/2.1.0/gems/sass-rails-5.0.3/lib/sass-rails
.rb:1:in `<top (required)>'
/home/deployer/.rvm/gems/ruby-2.1.5/gems/bundler-1.10.6/lib/bundler/runtime.rb:7
6:in `require'
/home/deployer/.rvm/gems/ruby-2.1.5/gems/bundler-1.10.6/lib/bundler/runtime.rb:7
6:in `block (2 levels) in require'
/home/deployer/.rvm/gems/ruby-2.1.5/gems/bundler-1.10.6/lib/bundler/runtime.rb:7
2:in `each'
/home/deployer/.rvm/gems/ruby-2.1.5/gems/bundler-1.10.6/lib/bundler/runtime.rb:7
2:in `block in require'
/home/deployer/.rvm/gems/ruby-2.1.5/gems/bundler-1.10.6/lib/bundler/runtime.rb:6
1:in `each'
/home/deployer/.rvm/gems/ruby-2.1.5/gems/bundler-1.10.6/lib/bundler/runtime.rb:6
1:in `require'
/home/deployer/.rvm/gems/ruby-2.1.5/gems/bundler-1.10.6/lib/bundler.rb:134:in `r
equire'
/var/www/myapp/releases/20150820100116/config/application.rb:7:in `<top (req
uired)>'
/var/www/myapp/releases/20150820100116/Rakefile:4:in `require'
/var/www/myapp/releases/20150820100116/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)
Читал и делал по
этому сабжу
Из отличий: вместо unicorn - passenger и вместо github - мой же сервер, где в соседней папке с сайтом валяется репозиторий, который я пушу с локального компа.