Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Capistrano 3.1 compile_assets_locally

I am trying to deploy a rails 4.1.0 application with this template https://github.com/TalkingQuickly/capistrano-3-rails-template/blob/master/Capfile. When I run

cap production deploy:setup_config

I get the error message

cap aborted!
Don't know how to build task 'deploy:compile_assets_locally'

Capfile

require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/rbenv'
require 'capistrano/rails/migrations'
# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }
Dir.glob('lib/capistrano/**/*.rb').each { |r| import r }

deploy.rb

set :application, 'myapp'

set :deploy_user, 'deployer'

set :scm, :git

set :repo_url, '[email protected]:~/.git/myapp.git'

set :rbenv_type, :system
set :rbenv_ruby, '2.1.1'
set :rbenv_prefix, "RBENV_ROOT=#{fetch(:rbenv_path)} RBENV_VERSION=#{fetch(:rbenv_ruby)} #{fetch(:rbenv_path)}/bin/rbenv exec"
set :rbenv_map_bins, %w{rake gem bundle ruby rails}

set :keep_releases, 5

set :linked_files, %w{config/database.yml}

set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}

set :tests, []

set(:config_files, %w(
  nginx.conf
  database.example.yml
  log_rotation
  monit
  unicorn.rb
  unicorn_init.sh
))

set(:executable_config_files, %w(
  unicorn_init.sh
))

set(:symlinks, [
  {
    source: "nginx.conf",
    link: "/etc/nginx/sites-enabled/{{full_app_name}}"
  },
  {
    source: "unicorn_init.sh",
    link: "/etc/init.d/unicorn_{{full_app_name}}"
  },
  {
    source: "log_rotation",
    link: "/etc/logrotate.d/{{full_app_name}}"
  }
])

namespace :deploy do

  before :deploy, "deploy:check_revision"
  before :deploy, "deploy:run_tests"
  after 'deploy:symlink:shared', 'deploy:compile_assets_locally'
  after :finishing, 'deploy:cleanup'
  before 'deploy:setup_config', 'nginx:remove_default_vhost'
  after 'deploy:setup_config', 'nginx:reload'
  after 'deploy:setup_config', 'monit:restart'
  after 'deploy:publishing', 'deploy:restart'
end
like image 975
markhorrocks Avatar asked Nov 11 '22 09:11

markhorrocks


1 Answers

The error message says that you did not define 'compile_assets_locally' task.

It seems you are including capistrano-rails gem already, so I think second method can fix your issue easily

  • First method: Define compile_assets_locally task. Copy template and place it under lib/capistrano/tasks directory (make sure the extension is .cap).

  • Second method: Using capistrano-rails gem

    • config/deploy.rb set :assets_roles, [:app]

      remove after 'deploy:symlink:shared', 'deploy:compile_assets_locally'

    • Capfile require 'capistrano/rails/assets'

like image 90
Chen Avatar answered Nov 14 '22 21:11

Chen