Posted 3 months ago. Visible to the public. Repeats.

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.

Once an application no longer requires constant development, it needs periodic maintenance for stable and secure operation. makandra offers monthly maintenance contracts that let you focus on your business while we make sure the lights stay on.

Owner of this card:

Avatar
Dominik Schöler
Last edit:
about 1 month ago
by Arne Hartherz
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Dominik Schöler to makandra dev
This website uses cookies to improve usability and analyze traffic.
Accept or learn more