I am deploying a Rails application using AWS OpsWorks. To precompile the assets, I use the following Chef recipe:
node[:deploy].each do |application, deploy|
deploy_to = node[:deploy][application][:deploy_to]
rails_env = node[:deploy][application][:rails_env]
directory "#{deploy_to}/shared/assets"
link "#{deploy_to}/current/public/assets" do
to "#{deploy_to}/shared/assets"
end
execute "rake assets:precompile" do
cwd "#{deploy_to}/current"
command "bundle exec rake assets:precompile"
environment "RAILS_ENV" => rails_env
end
end
It precompiles correctly, but in following deployments it goes through the whole precompile process again, even though no asset was modified and the assets folder is shared. I also tried a Chef hook, as suggested here, with the same result. How could you make it run only when needed?