Skip to content

Production Deployment (Mingle Story 1577)

nanravi edited this page Apr 30, 2013 · 1 revision

Setting up the web server

  • We support Ubuntu 12.04
  • Install the following core software:
sudo apt-get install ruby1.8 rubygems1.8 libxml2-dev libxslt1-dev build-essential git openjdk-7-jdk imagemagick openssh-server
  • Install latest CouchDB (1.2.x) from a PPA:
sudo apt-add-repository ppa:longsleep/couchdb
sudo apt-get update
sudo apt-get install couchdb
  • Install Nginx from a PPA:
sudo apt-add-repository ppa:brightbox/passenger-nginx
sudo apt-get update
sudo apt-get install nginx-full

Deploying to the Web Server

  • From the CI machine, go to the latest successful build folder (this is usually under /mnt/ci/TeamCity/buildAgent/work/)
  • This can also be done from your local development machine, provided you have setup RapidFTR in it as per the wiki pages for Linux/Mac/Windows
  • Run these commands to perform the deployment:
cap 
  -S deploy_server=<server name or IP address>
  -S deploy_user=<user name to login to the server>
  -S server_name=<DNS name which is used by end users to access the server>
  -S rails_env=production 
  -S http_port=80 
  -S https_port=443 
  -S solr_port=8983 
  -S couchdb_host=localhost
  -S couchdb_username=<username for couchdb, or empty for the first time>
  -S couchdb_password=<password for couchdb, or empty for the first time>
  -S nginx_site_conf=/etc/nginx/sites-enabled
  -S branch=<commit ID, or branch name like release1 or master>
deploy

Directory Structure after Deployment

A clear and standard directory structure will be created in the target Web Server for every deployment:

  • /srv/rapid_ftr_production/
    • releases/ - this contains all the releases done so far
    • current/ - symlink to releases/
      • log/ - symlink to shared/log
    • shared/
      • log/ - log files for the current release, these will never be overwritten during any release
        • server.log - Nginx HTTP server access logs
        • error.log - Nginx HTTP server error logs
        • production.log - Logs from the RapidFTR rails application
        • rapidftr-scheduler.output - Scheduler log
      • bundle/ - all shared ruby gems used for by RapidFTR

Securing CouchDB

  • The first time the app is deployed using the above cap command, you need to create a CouchDB administrator
  • Login to the web server where RapidFTR was just deployed, and run:
cd /srv/rapid_ftr_production/current
RAILS_ENV=production COUCH_USERNAME=<desired username> COUCH_PASSWORD=<desired password> bundle exec rake db:create_couch_sysadmin
  • After you've setup a password for CouchDB, from the next time when you're doing cap deploy, make use of that username and password for couchdb_username and couchdb_password
Clone this wiki locally