Skip to content

Instantly share code, notes, and snippets.

@ryanj
Created October 16, 2014 19:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanj/2643a9bb03f991de2af7 to your computer and use it in GitHub Desktop.
Save ryanj/2643a9bb03f991de2af7 to your computer and use it in GitHub Desktop.
Sails notes for OpenShift

Sails on OpenShift

You'll need node, npm, git, and rhc to follow along.

sudo npm install -g sails

Then complete the following:

  1. Use sails to generate a new app: sails new mysailsapp && cd mysailsapp
  2. Intialize the project with a new git repo: git init
  3. Create an OpenShift hosting environment for the app: rhc app create mysailsapp nodejs-0.10 --no-git --no-dns
  4. Record the resulting git remote url, adding it to your project's list of remotes: git remote add mysailsapp ssh://54401cd0597332fe2c00010b@mysailsapp-shifter.rhcloud.com/~/git/mysailsapp.git/
  5. update the project's package.json file to include sails and cloud-env as dependencies: npm install --save sails cloud-env
  6. adapt your config files to read from cloud-env (see below)
  7. remove node_modules from the project's .gitignore file. Build and deploy happens MUCH faster if the local node_modules folder is included.
  8. git add and commit your changes to the project source - including your updated package.json file, the config changes, and your node_modules folder: git add ., git commit -m 'generating a sales app that will run on OpenShift'
  9. Use git push mysailsapp to deploy updates to OpenShift. On your first push, use the --force option to clobber the current repo content (OpenShift's default "Hello World" project source).

To auto configure my app via cloud-env, I added the following to config/env/production.js:

var env = require('cloud-env')

module.exports = {  // this line should exist already, don't include it twice
  port: env.PORT,
  host: env.IP,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment