This repository has been archived by the owner on Jul 24, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 57
Capistrano Deployment Guide
Oren Kanner edited this page Sep 20, 2015
·
4 revisions
This guide will walk you through the process of deploying Reservations using Capistrano. The deployment scripts are intended to be as general as possible but have been written for use with Yale ITS and have not been extensively tested. Any feedback or help is always appreciated!
This script is designed to allow for stable deployment of Reservations onto a local server. In other words, it's meant to be called from the application server, not from the development machine. The script requires the following:
- A Linux webserver
- Ruby (using RVM) / Rails
- A local user named
hudson
with SSH access tolocalhost
- A valid configuration file
Reservations can be called using the following command:
cap deploy production
It requires three environment variables to be set:
-
GIT_TAG
: the Git reference to deploy; this can be either a tag or a branch name -
DEPLOY_DIR
: the directory to deploy Reservations into; the actual application code will be symbolically linked toDEPLOY_DIR/current
-
PARAM_FILE
: the location of the configuration parameter file for the instance to deploy; it is copied toDEPLOY_DIR/current/.env
In other words, a complete deployment command could look like:
GIT_TAG=v1.2.3 DEPLOY_DIR=/foo/www PARAM_FILE=/bar/baz.txt cap deploy production
In brief, the deployment script does the following:
- SSH's into
localhost
with userhudson
- Downloads the application code at the specified Git reference
- Runs database migrations
- Precompiles assets
- Copies the configuration parameter file into the
.env
file of the new release - Copies the production
database.yml
template intoconfig/database.yml
- Renames
config/secrets.yml.example
toconfig/secrets.yml
(used to pass-through configuration parameters) - If a GitHub authorization token is specified, renames
config/initializers/party_foul.rb.example
toconfig/initializers/party_foul.rb
- Updates the crontab using the whenever gem *production environment only*
- Touches the file
tmp/restart.txt
to tell Passenger / Apache to restart
Currently, this script has been tested in two scenarios:
- A DigitalOcean droplet running CentOS 6.7 + Apache + Passenger
- Yale ITS VM running RHEL 5.5 + Apache + Passenger
The success of this script in deployment architectures similar or dissimilar to these is not guaranteed; use at your own risk!