I am making a task that runs the slow composer install
command BEFORE the current
symlink is changed to point to the new release (because I don't want my new release to be broken for the first minute of it's life while the packaged are fetched).
before 'deploy:publishing', :composartisan do
on roles(:app) do
within fetch(:latest_release_directory) do
execute "cd #{current_path} && composer dump-autoload && composer install && php artisan storage:link && php artisan migrate"
end
end
end
This doesn't work because fetch(:latest_release_directory)
returns the current release, not the one that we are building and about to published in a few minutes time.
How can I fetch the folder path of the release we are building?
Found the solution myself. I needed to change 2 lines:
within fetch(:latest_release_directory)
became within release_path
cd #{current_path}
became cd #{release_path}
Here's the full working snippet...
before 'deploy:publishing', :composartisan do
on roles(:app) do
within release_path do
execute "cd #{release_path} && composer dump-autoload && composer install && php artisan storage:link && php artisan migrate"
end
end
end
Bit of a rant, but why is this not really documented on the Capistrano site? I found my solution by chance while browsing other Capistrano questions on StackOverflow. Now I look back I see release_path
is only mentioned once in the deploy:reverting section of the rollbacks page (http://capistranorb.com/documentation/getting-started/rollbacks/#deployreverting). A page that lists and explains all the variables that are made available seems like a basic essential to me.
[Not to be a back-seat-driver who bitches at open source, I will endeavour to fork the documentation and fix it myself when I feel my Capistrano skills are ninja enough to reliably write about it.]
</rant>