2010 / 11 / 21 — bundler, deploy, rails, ruby
When Rails 3.0.0.beta.1 was first released, there was some confusion about how to deploy a Rails3 app with this new Bundler thing. A few blog posts were written with some monkey patches for injecting into Capistrano, which enable early Bundler support. Unfortunately, Bundler was still very new and none of the deployment tools had official support yet.
Around the same time, I needed to deploy a Rails3 app and I did not want to
deal with the heavy weight of Capistrano; nor did I want to rely on a
monkey patch from a blog post. Of course the first thing I did was
look at the alternatives, which were
Vlad The Deployer or
write a bash script that used
git. After trying to run
vlad rake tasks, I hit some weird bugs with how it was calling
thin. Being on a dead-line and not wanting to wait on
Capistrano or Vlad, I thought it should be easy to create a simple
deployment utility with
Configuring DeploYML requires at least two things:
# config/deploy.yml source: firstname.lastname@example.org:user/project.git dest: email@example.com/var/www/site
Then one can deploy the project using the
$ deployml deploy
After making some changes, one can re-deploy the project:
$ deployml redeploy
Of course, one will want to specify more information, such as what server to run the project under:
source: firstname.lastname@example.org:user/project.git dest: email@example.com/var/www/site server: apache
Or what options to run the server with:
source: firstname.lastname@example.org:user/project.git dest: email@example.com/var/www/site server: name: thin options: servers: 4 deamonize: true socket: /var/run/thin.sock rackup: true
Or more importantly, what Framework or ORM the project uses:
source: firstname.lastname@example.org:user/project.git dest: email@example.com/var/www/site framework: rails3 orm: datamapper server: apache
One can even specify multiple-environments:
# config/deploy.yml source: firstname.lastname@example.org:user/project.git framework: rails3 orm: datamapper # config/deploy/staging.yml dest: ssh://email@example.com/srv/staging server: name: thin options: config: /etc/thin/staging.yml socket: /tmp/thin.staging.sock # config/deploy/production.yml dest: ssh://firstname.lastname@example.org/srv/project server: name: thin options: config: /etc/thin/example.yml socket: /tmp/thin.example.sock
DeploYML does more than just deploying, it also allows interacting with the deployment server and deployed project.
Need to quickly
ssh into the server as the deploy user?
$ deployml ssh
Need to quickly execute a command remotely, within the directory of the deployed project?
$ deployml exec 'ps aux'
Need to execute a rake task remotely?
$ deployml rake db:autoupgrade
Install it today:
$ gem install deployml
Note: I originally started DeploYML before Imploy was released, and just now got around to making a release. If you feel Capistrano is too heavy, I encourage you to also checkout Imploy for deploying Rails3 apps.