I am deploying a php project from git through the use of capistrano. I am currently minifying my javascript (using jammit) and css (using yui) through some capistrano tasks already. The issue I see is that I am doing this minification on the destination servers rather than once locally pre-deployment of the code base. The cause of concern is that I switched the javascript minification from yui to jammit and do not want to have to install this new ruby gem on multiple production servers when my deployment servers already have it installed. I inherited the capistrano file from anohter developer so I'm not 100% clear on the process of when the code gets checked out, and when it gets sent to the remote server, and what task I should hook into.
My initial thought is to do it before "deploy" but again, am not sure I'll have the source code available to act on.
The short answer is "you don't". The deploy hook calls deploy:update_code
deploy:update_code, {:except=>{:no_release=>true}}
Copies your project to the remote servers. This is the first stage of any deployment; moving your updated code and assets to the deployment servers. You will rarely call this task directly, however; instead, you should call the
deploy’ task (to do a complete deploy) or theupdate’ task (if you want to perform the `restart’ task separately).You will need to make sure you set the :scm variable to the source control software you are using (it defaults to :subversion), and the :deploy_via variable to the strategy you want to use to deploy (it defaults to :checkout).
Which does the following in one fell swoop:
(with some variation depending on your deployment settings).
However, I was able to to get around this by utilizing the download and upload commands.
tmp_path = "/tmp/#{release_name}/public"
download "#{current_path}/public/javascripts", "#{tmp_path}/javascripts/":via => :scp, :recurisve => true
system "jammit -o #{tmp_path}/javascripts -c #{tmp_path}/javascripts/assets.yml"
upload "#{tmp_path}/javascripts/common.js", "#{current_path}/public/javascripts", :via => :scp
system "rm -rf #{tmp_path}"
I don't like it as it's not quite as clean, but it gets the job done the way I need to get it done.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With