In this post I’ll cover the Strano and how to setup it to trigger cap deploy
task whenever you push/merge into the master branch of your project on GitHub.
Why Strano?
You might be wondering why we need a wrapper for a such great tool like Capistrano at all, so, here is advantages Strano gives you:
- Centralized Deployment Approach: Setup once
- History of Deployments: Who? When? What?
- Use Anywhere: Web Based
- Continuous Deployment (concept): trigger
cap deploywhen push/merge into the master branch.
Yes, those mostly valuable for the teams, but I believe single-man projects in some cases can also benefit from it.
Setup Strano for automatic deployments
Here is mostly typical for Strano installation except base_url variable
which can be set through the strano.yml as described below or environment
variable, e.g. STRANO_BASE_URL='http://example.com/' bundle exec rails s
Clone from my fork:
git clone git://github.com/yevgenko/strano.gitCheckout
push-deploybranch:cd strano git checkout -b push-deploy origin/push-deployConfigure database:
cp config/database.example.yml config/database.ymlNOTE: example file contains settings for sqlite3 database, but I’d recommended you to go with mysql to eliminate some weird transaction issues.
Bootstrap:
script/bootstrapConfigure Strano:
cp config/strano.example.yml config/strano.ymlThe following variables are mandatory for our setup:
# Strano's public SSH key with which it will attempt to clone Github repos via. public_ssh_key: MYPUBLICKEY # Strano's Github application client ID. See https://github.com/settings/applications github_key: github-application-client-id # Strano's Github application secret. See https://github.com/settings/applications github_secret: github-application-secret # Secret used to sign hook requests from GitHub. github_hook_secret: github-hook-secret # The application URL with a trailing slash, required for github hooks. # Can be passed as environment variable STRANO_BASE_URL='' # base_url: http://example.com/NOTE:
base_urlis where your application can be publicly accessed by GitHub’s servers. See Post-Receive Hooks article to learn more.Start the app:
bundle exec rails sOr whatever you do to start your rails application on the server.
Start the worker:
bundle exec sidekiqCheck out the Sidekiq website for assistance on Sidekiq and its options.
Usually it must be enough to have a Redis server up and running with default options.
That’s it! Once you sign-in with your GitHub account you will be able to start deploying your apps in no time.
Enjoy!
Additional Resources
Eric Ries post on continuous deployment
Local Tunnels
Services that allows you to share localhost web servers to the rest of the world: