Flexiant Concerto

We recently published a blog on how you can use Flexiant Concerto to easily put together a LAMP stack and deploy your application on top of it. Today we will take a look at another very widespread application stack requirement, that of Linux, Apache, MySQL and Ruby on Rails (LAMR).

Ruby’s versatility and maturity, together with the speed and agility it enables for developers, has given it widespread popularity. This has given rise to an extensive and active community, which has itself resulted in a broad range of feature-rich libraries for Ruby developers to choose from.

Just as with LAMP, manually setting up a LAMR stack can be a time-consuming process. Flexiant Concerto gives you an easy to use, GUI-based, drag and drop tool with which you can deploy a LAMR stack onto any cloud, in minutes. Regardless of which cloud you use, this will enable you to benefit from Flexiant Concerto features such as:

  • Integrated load balancer
  • Integrated DNS management, including geo-localization
  • Monitoring (via New Relic integration)

Let’s see how we can do this in just 4 steps (NB: you first need to sign up for Flexiant Concerto – it’s simple to try for free).

Step 1 – Create a template

  • Click Blueprint -> Templates
    • Click Add Template
      • Specify a name
      • Choose a generic image
      • Click New Template

Add Template

Step 2 – Configure the template

  • Click on the template just created
    • Click on Cookbooks
    • Choose the following cookbooks:
      • mysql::server@5.6.3 (under Databases)
      • ruby_helper@0.1.0 (under Development)
  • Change the following attributes;
    • mysql/server_root_password – [specify a password]
    • mysql/server_debian_password – [specify a password]
    • apt/compile_time_update – true
  • Click Save

Ruby on RailsRuby on Rails1

Step 3 – Add a script

Script to install and configure the Rails application

  • Click on Scripts on the left hand pane
    • Click Add Script
      • Specify a name and description
      • Save
    • Click on the script just created
    • Paste in the code section:
# avoid reinstalling
if [ ! -f /etc/init.d/tinyrails ];
  # Create database
  mysql -h localhost -u root -pHello.123 --execute='CREATE DATABASE example;'

  # Get rails application
  mkdir -p /var/rails/
  cd /var/rails/
  wget https://github.com/odacremolbap/apprails/archive/master.tar.gz
  tar zxvf master.tar.gz
  cd apprails-master

   # Configure rails application
  export RBENV_ROOT=/opt/rbenv
  export PATH=$RBENV_ROOT/bin:/opt/rbenv/plugins/ruby_build/bin:$PATH
  eval "$(rbenv init -)"
  rake db:seed
  # Create service
  BASEDIR=$(dirname $0)
  cp $BASEDIR/attachments/tinyrails.initd /etc/init.d/tinyrails
  chmod +x /etc/init.d/tinyrails

  service tinyrails start

Create a script attachment for a service that starts the Rails application

  • Create a file with the extension .initd
  • Enter the following content:
#! /bin/sh

# Provides:          tiny rails
# Required-Start:    $all
# Required-Stop:     $network $local_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts tiny rails
# Description:       starts tiny rails

SET_PATH="cd $APP_ROOT; rbenv rehash; rbenv local $RBENV_RUBY_VERSION"
DAEMON="rails s"
DAEMON_OPTS="-p 80 -b -d"
DESC="tiny rails"

case ${1-help} in
       su - $USER -c "$CMD"
       echo >&2 "Usage: $0 <start>"
       exit 1

exit 0
  • In Concerto, under Scripts, click on the Attachment tab
    • Click Select Files and upload the .initd file you just created
  • Click on the Code tab
  • Click on Save

Ruby on Rails2Ruby on Rails3

Associate script to template

  • Go back to Templates and click on the template just created
    • Click on Scripts in the right hand pane
      • Click on the + button in the Boot box
      • Select the script just created

Step 4 – Boot up a server

  • Click on Infrastructure -> Servers
    • Click Add Workspace
      • Specify a name, domain, SSH and firewall profile
      • Save
  • Click Add server
    • Specify name, hostname, template and cloud provider/server plan
    • Save
  • Click on the server just created
  • Click the green play button
  • Wait for the boot and bootstrapping process to complete
  • Browse to the Fully Qualified Domain Name listed under DNS in the right hand panel

You are now up and running with a fully functional Ruby stack.

To find out more about Flexiant Concerto or to signup and try it out for free, visit concerto.io.

Flexiant Concerto


Tags: , , , , , ,