From 74579a594038628048e0a59e0b5a682ede204e3f Mon Sep 17 00:00:00 2001 From: Hugh B Date: Thu, 11 Jan 2018 08:54:28 -0500 Subject: [PATCH] Update Capistrano sample & readme to Capistrano 3 --- extras/rails/ASSETS-README.md | 14 ++++++++------ extras/rails/config/deploy.rb.example | 6 ++++-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/extras/rails/ASSETS-README.md b/extras/rails/ASSETS-README.md index 02899ccc0..8dbd0e00c 100644 --- a/extras/rails/ASSETS-README.md +++ b/extras/rails/ASSETS-README.md @@ -93,21 +93,23 @@ $ heroku config:set NPM_CONFIG_PRODUCTION=false [https://devcenter.heroku.com/articles/nodejs-support#customizing-the-build-process]() -### Capistrano +### Capistrano 3 -All we need to do is add a task to run `yarn install` before we compile the assets. +All we need to do is add a task to run `yarn install && yarn run blendid -- build` before we compile the assets. The example below shows an example of using [nvm](https://github.com/creationix/nvm) (node version manager) to use the specified node version for your application. ```rb # ./config/deploy.rb -before "deploy:assets:precompile", "deploy:yarn_install" +before "deploy:assets:precompile", "deploy:blendid_build" namespace :deploy do - desc "Run yarn install" - task :yarn_install do - invoke_command "bash -c '. /home/deploy/.nvm/nvm.sh && cd #{release_path} && yarn install'" + desc "Install front end dependencies and compile for production with Blendid" + task :blendid_build do + on roles(:web), in: :groups, limit: 3, wait: 10 do + execute "bash -c '. /home/deploy/.nvm/nvm.sh && cd #{release_path} && yarn install && yarn run blendid -- build'" + end end end ``` diff --git a/extras/rails/config/deploy.rb.example b/extras/rails/config/deploy.rb.example index 2f901d303..ff03123bc 100644 --- a/extras/rails/config/deploy.rb.example +++ b/extras/rails/config/deploy.rb.example @@ -1,9 +1,11 @@ -# Using Capistrano? Use this file +# Using Capistrano 3? Use this file before "deploy:assets:precompile", "deploy:blendid_build" namespace :deploy do desc "Install front end dependencies and compile for production with Blendid" task :blendid_build do - invoke_command "bash -c '. /home/deploy/.nvm/nvm.sh && cd #{release_path} && yarn install && yarn run blendid -- build'" + on roles(:web), in: :groups, limit: 3, wait: 10 do + execute "bash -c '. /home/deploy/.nvm/nvm.sh && cd #{release_path} && yarn install && yarn run blendid -- build'" + end end end