Jordan Hammond | 04.25.16 | Code

Taperole: the Smashing Boxes Way to Deploy Your Rails App


  • Web

We all know the troubles of deploying. Days have been lost trying to get a project from your local computer to somewhere on the magic internet. Reasons for this may be many but examples could include: you’re deploying to a different kind of server, you have only deployed a very specific project to AWS, or the documentation may simply be so complex and overwhelming. We’ve all been there and Smashing Boxes hasn’t been an exception to this so no fear.

In Smashing Boxes’ infancy, Rails developers lost many a day deploying their work; especially if that work had separate front end and back end components. We knew that we needed to deploy our apps in a very specific, repeatable way to avoid the continuous loss of time that came with deployment. Lo and behold, this problem gave birth to Taperole.

Taperole is a gem specializing in the deployment of Rails apps. We’re not the first to try to tackle this problem of letting something do our deployments for us. But where Smashing Boxes really gets it right is that we make sure Taperole isn’t doing too much. It’s specifically (and only) for Rails apps that use PostgreSQL, with Nginx and Unicorn, on an Ubuntu 14 server. It’s not that other options are poor, it’s just that we needed consistency. So not only are our deploys easier at Smashing Boxes, but troubleshooting is that much easier as well.

How can YOU use Taperole for your Rails app?? Let me tell you…

1. Stand up an Ubuntu 14 server somewhere

We, at Smashing Boxes, use Digital Ocean. Not required by any means, but we find it easy to work with.

2. Add PostgreSQL and Unicorn to your Gemfile

Don’t forget to remove:

gem 'sqlite3'

And to: $ bundle install

Ensure your /config/database.yml file has been updated to something similar to this:

development:
adapter: postgresql
database: project_development
pool: 5
timeout: 5000

Ensure your .gitignore has these two lines:

config/secrets.yml
config/database.yml

3. Add Taperole to your Rails app

Taperole is built using Ansible Roles. So install (or upgrade if you already have it) Ansible with Brew.

$ brew install ansible

Now get that puppy into your Gemfile.

gem ‘taperole’

and $ bundle install

Run the Tape installer.

$ tape installer install

Update your hosts file with something similar:

[production]
0.0.0.0 be_app_env=production be_app_branch=SOME_BRANCH
[omnibox:children]
production

Copy your public key. If you’ve never made a public key before, follow this link. Once you’ve copied it, paste the key into a file in the /taperole/dev_keys directory (you can call that file [your_name].pub). Then reference that file in the tape_vars.yml.

dev_key_files:
— dev_keys/[your_name].pub

Fill in remaining missing values in tape_vars.yml. Should look something like this:

app_name: [app name]

be_app_repo: [git repo url (e.g. git@github.com:smashingboxes/foo.git)]

Add your private key (the one associated with your public key) to your ssh-add list. It’s easy:

$ ssh-add ~/.ssh/[your_private_key]

4. Commit all of these changes and push to whichever branch was specified in the hosts file

5. Run the big time command

$ tape ansible everything

Now pick up a nice book because this process is give or take 30 minutes. Curious about why it’s taking so long? Well, you’re installing EVERYTHING onto this server (Ruby, Nginx, etc). If you run into errors, rerun the command with $ tape ansible everything -vvvv. This will give you a much larger error output; you’ll definitely appreciate that.

6. SSH into your server

$ ssh [deployer]@[ip_address]

Create your config/secrets.yml and config/database.yml files.

$ cd config && touch secrets.yml && touch database.yml

Fill in config/secrets.yml. Should look something like this:

development:
secret_key_base: (some huge alpha-numeric code)

test:
secret_key_base: (some huge alpha-numeric code)

Fill in config/database.yml. Should look something like this:

default: &default
adapter: postgresql
pool: 5
timeout: 5000

development:
< database: project_development

production: &test
< database: project_production

And that should be it! Once you make changes to your app and have pushed them up, you can now just run:

$ tape ansible deploy

Conclusion

Using Taperole with all of our apps has reduced the amount of time we lose deploying from days to hours. And while it’s awesome that it has saved our company so much money (because time == money), we really want to share this openly with the rest of the world. We are dedicated to the Open Source community and we hope that Taperole can be used by many other developers. If you find it’s useful, or has issues, or anything else, please let us know in the repo!

Careers at Smashing Boxes


Open Positions

We don’t just make great products, we help build great companies.


Contact Us

Get exclusive access to Smashing Boxes news, case studies, and events.

Sign up now
close ×

Get exclusive access to Smashing Boxes news, case studies, and events. Sign up now!

* indicates required