Turbo Sprockets and capistrano

I recently added a turbocharged nut https://github.com/ndbroadbent/turbo-sprockets-rails3 for my rails application, I use capistrano to deploy on Amazon EC2.

I am a little confused about how I can do this job. assets: precompile worked on my local machine, but did not do this on the amazon instance.

The short brief capistrano instruction creates a new release directory for each deployment, and the public / assets directory is empty, so every time it creates a new one and when the assets are launched: precompilation, it will precompile all assets.

Should I precompile localy and add them to git or copy the public / assets directory from the last deployment before capistrano starts the assets: precompile?

What will be the cleanest / best solution?

/ Change Or, perhaps, save the compiled assets in a shared directory?

+4
source share
2 answers

The simplest solution I could think of is to use the shared / assets directory to store my assets and make a symbolic link to the release public / assets directory before compiling the assets.

task :assets_precompile do run "ln -s #{shared_path}/assets #{release_path}/public/assets" run "cd #{release_path} && RAILS_ENV=production bundle exec rake assets:precompile" end 

Edit: Anyan indicated that if you use deploy: assets (if you have load 'deploy/assets' in your Capfile), this is done by default, so a cleaner solution.

+6
source

Lesce's answer has more weight if the deployment process involves symbolic linking to static files.

Example: config / database.yml is something that you do not configure, and do not want the deployment to necessarily change for you ... The presence in shared / assets will lead to a failure when activating assets: precompile.

It also works for cases with user-uploaded images, attachments ...

+1
source

All Articles