Capistrano Deployment Guide - YaleSTC/reservations GitHub Wiki
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!
Overview
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
hudsonwith SSH access tolocalhost - A valid configuration file
Syntax
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 nameDEPLOY_DIR: the directory to deploy Reservations into; the actual application code will be symbolically linked toDEPLOY_DIR/currentPARAM_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
Procedure
In brief, the deployment script does the following:
- SSH's into
localhostwith userhudson - Downloads the application code at the specified Git reference
- Runs database migrations
- Precompiles assets
- Copies the configuration parameter file into the
.envfile of the new release - Copies the production
database.ymltemplate intoconfig/database.yml - Renames
config/secrets.yml.exampletoconfig/secrets.yml(used to pass-through configuration parameters) - If a GitHub authorization token is specified, renames
config/initializers/party_foul.rb.exampletoconfig/initializers/party_foul.rb - Updates the crontab using the whenever gem *production environment only*
- Touches the file
tmp/restart.txtto tell Passenger / Apache to restart
Testing
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!