Menu

Sherri Flemings

Software Swiss Army Knife • Textile Hobbyist • Gamer • Foodie •

Auto install Bolt Extensions

I'm using DeployBot as my continuous delivery machine for this site. Bolt CMS is still fairly new to me so perhaps I overlooked some important details in the docs about setting it up. I managed to get the deploy script up and running quickly but every time I push new code to the repo 2 things were breaking:

  • Extensions - I have to manually re-install the extensions after each deploy
  • Files - the link to the files directory gets broken

These are definitely caused by mistakes I made while slapping together my initial deploy script. Since I have a tiny bit of time left before my vacation ends why not fix it while it's still fresh in my mind?

Auto install extensions on deploy

Since Bolt extensions are composer dependencies this was a super easy fix. I just added to the Composer post-install script:

post-install-cmd


cd extensions && composer install --no-interaction

This just runs the composer file for extensions.

Fix the files symlink

I'm using DeployBot's atomic deploy option, which was inspired by Capistrano. The bonus here is that I don't need to maintain the scripts on my server. Since it updates the current directory symlink to point to the latest release on each deploy there are some files (like media uploads, htaccess, etc) that are kept in the shared directory. 

My first crack at configuring the shared folder symlinks:


ln -s $SHARED/files $RELEASE/public/files

My server files are saved to $SHARED/files and this code is making sure that when BoltCMS looks for the files directory it's pointing to the right path. Well... almost the right path. Since I'm esentially rebuilding the app from scratch on every deploy, that also means it's creating that files directory. So when I try to create the symlink Ubuntu sees that a files directory already exists and so creates a new symlink inside of it. It looked like this:


$RELEASE
 └── public
      └── files 
            └── files ← symlink

Now that I see what's happening it was another quick fix:

Updated symlink command


# remove the newly generated files directory so we can create the symlink instead
rm -rf $RELEASE/public/files
ln -s $SHARED/files $RELEASE/public/files

Deploy script done!

comments powered by Disqus