Deploying Refinery CMS in a few easy steps

Refinery is totally free open source content management system. Today I'll demonstrate how to deploy it on Shelly Cloud.

Prerequisites

Before moving on to Refinery, first make sure you have the required system tools installed:

  • Ruby, version 1.9.3 or higher. On Shelly Cloud default Ruby version is 2.0.0 and it's generally better to have the same version locally.
  • Working compiler (to install gems with native extensions)
    • on OS X you will need XCode with command line tools
    • for Ubuntu install at least build-essential and autoconf packages
  • PostgreSQL headers
    • for OS X install postgresql via Postgres.app
    • for Ubuntu it will be required to have libpq-dev installed

Microsoft Windows isn't supported. We strongly discourage trying this walkthrough on operating systems different than OS X or Linux.

As for gems, you will need to install:

  • Shelly
  • RefineryCMS - it’s used to generate drafts of your future application
  • ExecJS - it isn’t installed with Refinery gem but it’s required

You can do it by executing following command gem install shelly execjs refinerycms.

Step by step installation guide

  1. If you don't have a Shelly Cloud account yet use our sign up page to create one.

  2. Login to Shelly Cloud via command line.

   $ shelly login
   Email (you@example.com - default): [enter your email]
   Password: [enter your password]
   Login successful
   Uploading your public SSH key
  1. Now, we'll create our refinery-with-shelly application scaffold.
   $ refinerycms refinery-with-shelly
   ...
   === ACTION REQUIRED ===
   Now you can launch your webserver using:

   cd refinery-with-shelly
   rails server

   This will launch the built-in webserver at port 3000.
   You can now see Refinery running in your browser at http://localhost:3000/refinery

   Thanks for installing Refinery CMS, we hope you enjoy crafting your application!
   ————
  1. Go to refinery-with-shelly directory:
   $ cd refinery-with-shelly
  1. Edit Gemfile and add :production group to the end of file.
   group :production do
     gem "shelly-dependencies"
     gem "pg"
   end

Added gems are standard shelly dependencies for Rails application with PostgreSQL database.

  1. To have assets working it’s required to use Shelly Cloud deployment hook support

a. First, update your environment configuration (usually config/environments/production.rb) with following line:

  ```ruby
  # Enable serving assets, use far-future expiry header
  config.static_cache_control = "public, max-age=31536000"
  ```

b. Create three hook files which will set up sharing assets between virtual servers after precompilation.

  ```bash
  # config/deploy/shelly/link_assets_from_disk

  set -e

  # Link public/assets to disk/assets if needed
  if [ ! -L "public/assets" ]; then
      if [ -d "public/assets" ]; then
        rmdir public/assets
      fi
      mkdir -p disk/assets
      ln -s ../disk/assets public/assets
  fi
  ```

  ```bash
  # config/deploy/shelly/before_migrate

  set -e

  # Make sure that public/assets is linked to disk/assets
  config/deploy/shelly/link_assets_from_disk

  # Precompile assets (this happens only on one of the servers)
  rake assets:precompile
  ```

  ```bash
  # config/deploy/shelly/before_restart

  set -e

  # Make sure that public/assets is linked to disk/assets
  config/deploy/shelly/link_assets_from_disk
  ```

c. Add execute permission for link_assets_from_disk

  ```bash
  $ chmod +x config/deploy/shelly/link_assets_from_disk
  ```
  1. Now run bundle install.

  2. Test the application in local environement.

a. Precompile static assets.

  ```bash
  $ rake assets:precompile
  ```

b. Add public/assets to .gitignore file. We don't want to have all these files commited to the repository.

c. Run migrations

  ```bash
  $ RAILS_ENV="production" rake db:migrate
  ```

d. Run application

  ```bash
  $ rails s -e production
  ```

e. You can see it by entering http://localhost:3000/refinery in your browser. You can stop your local Rails server using CTRL+C.

  1. Initialize git repository and add all files to it.
   $ git init
   $ git add .
   $ git commit -m "Initial commit of my Refinery instance"
  1. Create an application on Shelly Cloud (you can respond to all questions with the default action).

    $ shelly add
    $ git add Cloudfile
    $ git commit -m "Add application to Shelly Cloud"
    $ git push shelly master
    
  2. Start the newly created cloud

    $ shelly start
    
  3. Go to http://refinery-with-shelly.shellyapp.com/refinery and create a first account.

    Account Creation Welcome Page

  4. Next you can continue with refinery guides.

We encourage you to try ShellyCloud with RefineryCMS by yourself. It's really simple!


Shelly Cloud is a platform for hosting Ruby and Ruby on Rails applications. You can focus on development without getting distracted by deployment, optimization and maintenance.


Want to be up-to-date with Shelly?

Follow us on Twitter and get latest news about platform, ongoing issues and blog posts.

Talk to a human