My ruby on rails app take about half an hour to complete a deployment. The longest step is
RAILS_ENV=production RAILS_GROUPS=assets bundle exec rake assets:precompile
which takes about 1073155ms
I have to wait for a long time for each deployment.
I use
ckeditor
rails_admin
I guess it is them who slow down my deployment, but I don't evidence and I don't know how to
solve it, either.
My other environments are as follows:
rails 4.0.3
ruby 2.1.1
My production.rb about assets is
config.serve_static_assets = false
# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
# config.assets.css_compressor = :sass
# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = true
# Generate digests for assets URLs.
config.assets.digest = true
# Version of your assets, change this if you want to expire all your assets.
config.assets.version = '1.0'
Try to skip compiling ckeditor assets
config/environments/production.rb
require_relative '../../lib/assets/selective_assets_compressor'
config.assets.js_compressor = SelectiveAssetsCompressor.new
lib/assets/selective_assets_compressor.rb
class SelectiveAssetsCompressor < Uglifier
def initialize(options = {})
super(options)
end
def compress(string)
if string =~ /CKSource/
string
else
super(string)
end
end
end
For faster asset precompiles, you can setting config.assets.initialize_on_precompile to false in config/application.rb. Heroku requires this to be false.
config.assets.initialize_on_precompile = false
If you do that, be sure to test rake assets:precompile locally because the complete environment is not loaded, engines (or other gems) will not be loaded, which can cause missing assets.
In the other hand you can execute asset precompile before deploy locally and deploy the files precompiled.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.