Capistrano: Speeding up Sprockets' asset compile during deploy
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 Sprockets cache directory to shared directories
Sprockets is the library behind Rails' asset pipeline. It keeps a cache of already compiled files, so when a single file changes, it only needs to rebuild that one. This is exactly what makes asset compilation so fast in development. We're gonna leverage the cache for deployments now.
In Capistrano 3, add tmp/cache/assets/sprockets
to your linked directories:
Copy# deploy.rb set :linked_dirs, %w[log public/system tmp/cache/assets/sprockets …]
If you want to do this for a specific stage only, do this instead:
Copy# deploy/staging.rb append :linked_dirs, 'tmp/cache/assets/sprockets'
In Capistrano 2 you need to link the directory manually.
Your development team has a full backlog of feature requests, chores and refactoring coupled with deadlines? We are familiar with that. With our "DevOps as a Service" offering, we support developer teams with infrastructure and operations expertise.