Module: MagicRecipes::Assets
- Defined in:
- lib/magic_recipes/assets.rb
Overview
Assets - Deploy-Recipes
changed asset deployment .. include chmod 777 for public folder (my server need this)
- Tasks:
-
:symlink # => set up a symlink to the shared directory
:precompile # => Run the asset precompilation rake task
:chmod # => make the public folder public for all (777)
:clean # => Run the asset clean rake task
- Callbacks:
-
before ‘deploy:finalize_update’, ‘deploy:assets:symlink’
after ‘deploy:update_code’, ‘deploy:assets:precompile’
Class Method Summary collapse
Class Method Details
.load_into(configuration) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/magic_recipes/assets.rb', line 22 def self.load_into(configuration) configuration.load do set_default :asset_env, "RAILS_GROUPS=assets" set_default :assets_prefix, "assets" set_default :assets_role, [:web] set_default :normalize_asset_timestamps, false set_default :make_pulbic_folder_public, false before 'deploy:finalize_update', 'deploy:assets:symlink' after 'deploy:update_code', 'deploy:assets:precompile' namespace :deploy do namespace :assets do desc <<-DESC [internal] This task will set up a symlink to the shared directory \ for the assets directory. Assets are shared across deploys to avoid \ mid-deploy mismatches between old application html asking for assets \ and getting a 404 file not found error. The assets cache is shared \ for efficiency. If you customize the assets path prefix, override the \ :assets_prefix variable to match. DESC task :symlink, :roles => assets_role, :except => { :no_release => true } do # => sudo chown <username> . run <<-CMD #{sudo if use_sudo} rm -rf #{latest_release}/public/#{assets_prefix} && #{sudo if use_sudo} mkdir -p #{latest_release}/public && #{sudo if use_sudo} mkdir -p #{shared_path}/assets && #{sudo if use_sudo} ln -s #{shared_path}/assets #{latest_release}/public/#{assets_prefix} CMD end desc <<-DESC Run the asset precompilation rake task. You can specify the full path \ to the rake executable by setting the rake variable. You can also \ specify additional environment variables to pass to rake via the \ asset_env variable. The defaults are: set :rake, "rake" set :rails_env, "production" set :asset_env, "RAILS_GROUPS=assets" DESC task :precompile, :roles => assets_role, :except => { :no_release => true } do if make_pulbic_folder_public chmod end if use_rvm run <<-CMD #{rvm_cmd} && cd #{latest_release} && #{rake} RAILS_ENV=#{rails_env} #{asset_env} assets:precompile CMD else run <<-CMD cd #{latest_release} && #{rake} RAILS_ENV=#{rails_env} #{asset_env} assets:precompile CMD end end desc "make the public folder public for all (777)" task :chmod, :roles => assets_role, :except => { :no_release => true } do run <<-CMD cd #{latest_release} && #{sudo} chmod -R 777 public/ && #{sudo} chmod -R 777 tmp/ CMD run <<-CMD cd #{shared_path} && #{sudo} chmod -R 777 assets/ CMD end desc <<-DESC Run the asset clean rake task. Use with caution, this will delete \ all of your compiled assets. You can specify the full path \ to the rake executable by setting the rake variable. You can also \ specify additional environment variables to pass to rake via the \ asset_env variable. The defaults are: set :rake, "rake" set :rails_env, "production" set :asset_env, "RAILS_GROUPS=assets" DESC task :clean, :roles => assets_role, :except => { :no_release => true } do if make_pulbic_folder_public chmod end if use_rvm run <<-CMD #{rvm_cmd} && cd #{latest_release} && #{rake} RAILS_ENV=#{rails_env} #{asset_env} assets:clean CMD else run <<-CMD cd #{latest_release} && #{rake} RAILS_ENV=#{rails_env} #{asset_env} assets:clean CMD end end end end end end |