Taperole: the Smashing Boxes Way to Deploy Your Rails App

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 installEnsure 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 installRun 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!

Subscribe to the Smashing Boxes Blog today!

Smashing Boxes is a creative technology lab that partners with clients, taking an integrated approach to solving complex business problems. We fuse strategy, design, and engineering with a steady dose of entrepreneurial acumen and just the right amount of disruptive zeal. Simply put, no matter what we do, we strive to do it boldly. Let's talk today!

Related Posts

Smashing Boxes is Now Part of Unboxed Ventures

Smashing Boxes is now part of Unboxed Ventures. See what the next chapter of entrepreneurship means for us.

view post

The Foundation of Digital Transformation

Digital Transformation -- the pivotal process of using emerging or new technologies to modify or improve how your organization or product functions; improving your business processes, corporate culture, and customer experiences to align with evolving market dynamics.

view post