40 cards
Posted over 1 year ago. Visible to the public.

Capistrano 3: assets:precompile only on one server


This should not be necessary in any case and is only for special cases, for e.g. if the assets directory is linked to a shared storage (for e.g. glusterfs). Please mind that it isn't wise to move your assets directory to a shared storage. The data in this directory should always be reproducible on all appservers when executing a assets precompile (so you don't need to sync this data). Other data should not be stored in the assets directory.
User uploads or files generated by requests should be stored in public/system.

Execute assets:precompile only on one server with Capistrano 3

If the assets directory is linked to glusterfs asset:precompile should only be executed on one of the appservers.

The asset precompile is by default executed on all Servers with the role web. You can overwrite this in deploy.rb:

set :assets_roles, [:assets]

This tells Capistrano that only the role :assets should precompile assets.

Now you need to add the :assets role to one of your servers in your deployment configuration (deploy/production.rb, `deploy/staging.rb, …). If you miss this, no asset precompile will be executed when deploying:

server 'app01-stage.acme.makandra.de', user: 'deploy-acme_s', roles: %w(app web cron db assets) server 'app02-stage.acme.makandra.de', user: 'deploy-acme_s', roles: %w(app web db)

Owner of this card:

Claus-Theodor Riegg
Last edit:
over 1 year ago
by Claus-Theodor Riegg
This website uses cookies to improve usability and analyze traffic.
Accept or learn more