lib/shuttle/deployment/rails.rb in shuttle-deploy-0.2.0.beta12 vs lib/shuttle/deployment/rails.rb in shuttle-deploy-0.2.0.beta13
- old
+ new
@@ -13,10 +13,14 @@
def precompile_assets?
config.rails && config.rails.precompile_assets != false
end
+ def cache_assets?
+ config.rails && config.rails.cache_assets == true
+ end
+
def start_server?
if config.rails && !config.rails.start_server.nil?
config.rails.start_server
else
true
@@ -41,13 +45,33 @@
if res.failure?
error "Unable to run rake command: #{command}. Reason: #{res.output}"
end
end
+ # Precompile rails assets. If no changes detected between last and
+ # current releases, precompile task will be skipped.
def precompile_assets
if precompile_assets?
- log "Precompiling assets"
- rake 'assets:precompile'
+ precompile = true
+
+ # Detect if there any change in assets
+ if cache_assets? && last_version != version
+ old_path = deploy_path("releases/#{last_version}")
+ new_path = release_path
+
+ result = ssh.run("diff -arq #{old_path}/app/assets #{new_path}/app/assets")
+ if result.success?
+ precompile = false
+ ssh.run("cp -a #{old_path}/public/assets #{new_path}/public/")
+ end
+ end
+
+ if precompile
+ log "Precompiling assets"
+ rake 'assets:precompile'
+ else
+ log "Asset procompilation skipped"
+ end
end
end
def deploy
ssh.export('RACK_ENV', rails_env)
\ No newline at end of file