You'll need node
, npm
, git
, and rhc
to follow along.
sudo npm install -g sails
Then complete the following:
- Use sails to generate a new app:
sails new mysailsapp && cd mysailsapp
- Intialize the project with a new git repo:
git init
- Create an OpenShift hosting environment for the app:
rhc app create mysailsapp nodejs-0.10 --no-git --no-dns
- 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/
- update the project's
package.json
file to includesails
andcloud-env
as dependencies:npm install --save sails cloud-env
- adapt your config files to read from
cloud-env
(see below) - remove
node_modules
from the project's.gitignore
file. Build and deploy happens MUCH faster if the local node_modules folder is included. - git add and commit your changes to the project source - including your updated
package.json
file, theconfig
changes, and yournode_modules
folder:git add .
,git commit -m 'generating a sales app that will run on OpenShift'
- 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,