-
Notifications
You must be signed in to change notification settings - Fork 49
Continuous Deployment with whiskey_disk
Continuous deployment rocks. Whiskey_disk makes it super easy. Here's how to set it up on your servers.
gem install whiskey_disk
Make sure to take note of your gem install location, as we'll need to be explicit about the
location of the wd
binary for the cron task in the next step. Hint: If you're using rvm
on your deployment
machine, it probably won't be /usr/local/bin/wd
. Whatever the install location, knowing the exact
install path is important because Cron runs with an extremely minimal
envionment setup, so it's best to assume that your $PATH variable is not set at all.
The easiest way to do this is simply to run which wd
, and use this in the cron task in the
next step (the crontab below assumes the which wd
output is /usr/local/bin/wd
).
When logged in as the user who performs the deploys, edit that user's crontab:
crontab -e
# Run every minute
* * * * * /usr/local/bin/wd --check --only=myapp.com --path=/var/www/shared/config/deploy.yml deploy
Let's walk through what's going on in the crontab.
The first part (prior to /usr/local/bin/wd) is the cron interval specification.
I won't attempt to explain in entirety cron's archaeic interval specification format here,
but plenty of documentation exists on this topic. The relevant part for our purposes is the first *
, which indicates to cron, "run this every minute". If you wanted to run this say, every five minutes, simply change this to */5
.
The --check
flag tells whiskey_disk to check if HEAD in the remote repository is different from the local
HEAD. If it is, whiskey_disk runs a deploy, per the instructions defined in the deploy.yml
config file.
Otherwise it does nothing.
The --only
flag is how you tell wd to do a "local" deploy to the specified domain. "Local" means that wd
won't attempt to ssh into the specified domain -- it will execute the deployment on the local filesystem.
Note: The --only
flag is also useful if you have multiple domains specified for a single deployment target
(i.e. you're deploying to multiple servers) and you only want to deploy to one of them.
The --path
flag is the path to the application's deploy.yml file.
Now, all you have to do is push to the remote specified in your deploy.yml, and whiskey will check every minute and deploy if anything has changed. That's it. Seriously. Happy hacking!