Skip to content

Deploying Tower Apps

Lance Pollard edited this page Oct 2, 2012 · 5 revisions

Deploying Tower Apps

The following hosting solutions can be used for Node.js apps:

Deployment Platforms

Paid Deployment Platforms

Free Deployment Platforms

Deployment Environments

  • staging
  • production
  • demo

Deploying to Heroku

In the simple case, just deploy straight to production. For "real" or live apps, a staging environment is important. It mimics your production environment. Push there first to make sure the latest code doesn't break anything. Modify code if things do break, try again. Then push to production. Also, have a live "development" environment, where you can push your daily hacks even before staging to see how things are going. For demoing the app, have a dedicated "demo" deployment that's as close to possible to staging but isn't volatile.

Setup (for Heroku)

First, create apps on the Cedar stack:

heroku create <%= app.name %> --stack cedar # production
heroku create <%= app.name %>-development --stack cedar
heroku create <%= app.name %>-staging --stack cedar
heroku create <%= app.name %>-demo --stack cedar

Then link to them:

git remote add production [email protected]:<%= app.name %>.git
git remote add development [email protected]:<%= app.name %>-development.git
git remote add staging [email protected]:<%= app.name %>-staging.git
git remote add demo [email protected]:<%= app.name %>-demo.git

Create Branches

Develop using the same branching structure. First, create the branches:

git branch development
git branch staging
git branch demo

Then checkout a branch and develop:

git checkout development

Change some code and commit the changes:

git add . ; git commit -a -m 'added code to dev branch'

Pushing to Heroku

Push to Heroku using the robustness of git push:

git push <remote> <local-branch>:master

Where remote is the name given to app (development for <%= app.name %>-development), and local-branch is the branch you're working on (development).

git push development development:master

Merging branches

To merge committed development changes to the other three branches and push all of the code to the respective remotes (I know it sounds like a lot, but it's definitely worth it), do this:

git checkout staging
git merge development
git push staging staging:master
# if no errors, nice! push to production
git checkout master
git merge staging
git push production master
# for the demo site
git checkout demo
git merge master
git push demo demo:master

Logging

heroku logs --app <%= app.name %>-development -n 500 --tail

Notes

Heroku defaults to Node 0.4.0. To use your own version of node, check this out:

Deploying to Nodejitsu

Delete design.io in devDependencies as it will cause an issue. This issue has been flagged by nodejitsu.

Put this at the top of config/application.coffee:

if process.env.NODE_ENV == 'production'
  Tower.Application::watch = ->
  Tower.env = 'production'

Deploying to Amazon EC2

  • web sockets
  • mongodb
  • redis
  • email

Deploying to Windows Azure

You can deploy to Windows Azure from Windows, Mac, or Linux:

azure site --help
azure site portal
azure site log download <app-name>

On your azure dashboard, set app settings variable NODE_ENV to production.

There's also some way to create a custom web.config file at the root, for iisnode, if you figure it out please post!

Deploying to DotCloud

$ dotcloud create towertest
Created application "towertest" using the flavor "sandbox" (Use for development, free and unlimited apps. DO NOT use for production.).
This flavor cannot be changed.

** YOU HAVE CREATED A SANDBOX APPLICATION **
SANDBOX applications may not be scaled, may not use custom domains,
and do not have the same performance guarantees as "live" applications.
SANDBOX applications cannot be upgraded.

Information about the different flavors offered can be found here:
http://docs.dotcloud.com/guides/flavors/

Deploying to OpenShift

Deploying to No.de

Monitoring Tower Apps

Clone this wiki locally