Is it possible to compile Symfony2 assetic:dump and deploy that rather than run it on the server?
That's a bit tricky, I'm also trying to do this (java is not working properly on my server, so deployment fails).
The problem is that Capifony deploys from a source control repository, and usually dumped assets are not on the repository (and they shouldn't).
So I guess the only way to do this is to create a Capistrano task (Capifony is based on Capistrano) that will dump the assets and rsync them on the server.
Edit : Here's my attemptEdit : It does work, I've been using it since I answered the question.
I'm sure there are plenty of possible improvements, I'm not a ruby guy, I'm not a shell script guy either.
In your deploy.rb you can add two tasks :
before "deploy:update_code", "deploy:dump_assetic_locally"after "deploy:update_code", "deploy:rsync_local_assets_to_server"
And the code associated to those tasks (in the same file) :
namespace :deploy do task :dump_assetic_locally, :roles => :web do run_locally "php app/console assetic:dump --env=prod" end task :rsync_local_assets_to_server, :roles => :web do finder_options = {:except => { :no_release => true }} find_servers(finder_options).each {|s| run_locally "rsync -az --delete --rsh='ssh -p #{ssh_port(s)}' #{local_web_path}/js/ #{rsync_host(s)}:#{release_path}/web/js/" } find_servers(finder_options).each {|s| run_locally "rsync -az --delete --rsh='ssh -p #{ssh_port(s)}' #{local_web_path}/css/ #{rsync_host(s)}:#{release_path}/web/css/" } end def local_web_path File.expand_path("web") end def rsync_host(server) :user ? "#{user}@#{server.host}" : server.host end def ssh_port(server) server.port || ssh_options[:port] || 22 endend
The command assetic:dump
takes the assets from all the bundles avaiable in the current environment and places them in web/bundles
(or where you tell it to). There should be no problem in doing this locally and then just moving the files.
You should run the command with the env=prod
option to ensure all bundles which are needed in production are getting generated. You migh also want to clean the web/bundles
before running the command so the assets for bundles which are only used in development (e.g. profiler) are not present.
I would simply do a test by running the command locally, download the assets from production and compare them. I cannot think of anything right now as css and js gets served to the client and should not be different when generated on different machines, but I might be wrong.
Is very simpleadd to your deploy.rb
set :dump_assetic_assets, true