Sha256: af0aaba2a3bd719d003f795f153a7f8adf90d81e9315ac76af33481662f0b366

Contents?: true

Size: 1.28 KB

Versions: 94

Compression:

Stored size: 1.28 KB

Contents

# Clear existing task so we can replace it rather than "add" to it.
Rake::Task["deploy:compile_assets"].clear 

namespace :deploy do
  
  desc 'Compile assets'
  task :compile_assets => [:set_rails_env] do
    # invoke 'deploy:assets:precompile'
    invoke 'deploy:assets:precompile_local'
    invoke 'deploy:assets:backup_manifest'
  end
  
  
  namespace :assets do
    
    desc "Precompile assets locally and then rsync to web servers" 
    task :precompile_local do 
      # compile assets locally
      # run_locally do
      #   with rails_env: fetch(:stage) do
      #     execute :bundle, "exec rake assets:precompile"
      #   end
      # end
      run_locally do
        execute "RAILS_ENV=#{fetch(:stage)} bundle exec rake assets:precompile"
      end

      # rsync to each server
      local_dir = "./public/assets/"
      on roles( fetch(:assets_roles, [:web]) ) do
        # this needs to be done outside run_locally in order for host to exist
        remote_dir = "#{host.user}@#{host.hostname}:#{release_path}/public/assets/"
    
        run_locally { execute "rsync -av --delete #{local_dir} #{remote_dir}" }
        
        execute :sudo, :chmod, "-R 777 #{release_path}/public"
      end

      # clean up
      run_locally { execute "rm -rf #{local_dir}" }
    end
    
  end
  
end

Version data entries

94 entries across 94 versions & 1 rubygems

Version Path
magic_recipes_two-0.0.95 lib/capistrano/tasks/assets.rake
magic_recipes_two-0.0.94 lib/capistrano/tasks/assets.rake
magic_recipes_two-0.0.93 lib/capistrano/tasks/assets.rake
magic_recipes_two-0.0.91 lib/capistrano/tasks/assets.rake
magic_recipes_two-0.0.90 lib/capistrano/tasks/assets.rake
magic_recipes_two-0.0.89 lib/capistrano/tasks/assets.rake
magic_recipes_two-0.0.88 lib/capistrano/tasks/assets.rake
magic_recipes_two-0.0.87 lib/capistrano/tasks/assets.rake
magic_recipes_two-0.0.86 lib/capistrano/tasks/assets.rake
magic_recipes_two-0.0.85 lib/capistrano/tasks/assets.rake
magic_recipes_two-0.0.84 lib/capistrano/tasks/assets.rake
magic_recipes_two-0.0.83 lib/capistrano/tasks/assets.rake
magic_recipes_two-0.0.82 lib/capistrano/tasks/assets.rake
magic_recipes_two-0.0.81 lib/capistrano/tasks/assets.rake
magic_recipes_two-0.0.80 lib/capistrano/tasks/assets.rake
magic_recipes_two-0.0.79 lib/capistrano/tasks/assets.rake
magic_recipes_two-0.0.78 lib/capistrano/tasks/assets.rake
magic_recipes_two-0.0.77 lib/capistrano/tasks/assets.rake
magic_recipes_two-0.0.76 lib/capistrano/tasks/assets.rake
magic_recipes_two-0.0.75 lib/capistrano/tasks/assets.rake