Remember How to skip Sprockets asset compile during Capistrano deployment and Automatically skipping asset compilation when assets have not changed? Turns out there is an even better way to speed up Capistrano deployments with asset compilation – and it's even simpler.
Adding the asset cache directory to symlinked directories
Popular asset managers for Rails are Sprockets and Webpacker. Both keep a cache of already compiled files that we're going to leverage for deployments now.
- Sprockets cache directory:
tmp/cache/assets/sprockets
- Webpacker cache directory:
tmp/cache/webpacker
(checkcache_path:
inconfig/webpacker.yml
to be sure)
In Capistrano 3, add the cache directory to your linked directories:
# deploy.rb
set :linked_dirs, %w[log public/system … $cache-directory]
If you want to do this for a specific stage only, do this instead:
# deploy/staging.rb
append :linked_dirs, $cache-directory
In Capistrano 2 you need to link the directory manually.
Posted by Dominik Schöler to makandra dev (2018-12-19 07:50)