-
Notifications
You must be signed in to change notification settings - Fork 5
Deployment
##Introduction
- Identity Providers
- DB on MongoLab
- API Server on Heroku
- HTML 5 web app on Google Drive and Dropbox
- Phonegap web app
##Identity Providers
Configure identity providers at:
- Google: https://console.developers.google.com/project
- Facebook: https://developers.facebook.com/apps/
- Twitter: https://apps.twitter.com/app/
- Windows Live: https://account.live.com/developers/applications
Check https://github.com/jlchereau/Phonegap.Express/issues/16.
Update https://github.com/jlchereau/Phonegap.Express/blob/master/config/production.json accordingly.
##DB on MongoLab
Go to http://www.mongolab.com, register and create a database and a db user on AWS. Copy the URI in the form mongodb://<dbuser>:<dbpassword>@ds063178.mongolab.com:63178/expressjs to https://github.com/jlchereau/Phonegap.Express/blob/master/config/production.json.
You can use Robomongo to test your connection.
##API Server on Heroku
Go to http://www.heroku.com, register and create an application named expressjs
, preferably in the same AWS region as MongoDB.
Create a file named Procfile
at the root of the project with the following content:
web: node server.js
Update package.json
with the nodeJS version to run against:
"engines": {
"node": "v0.10.x"
}
Install the heroku toolbelt and login to heroku to upload an SSH public key:
>heroku login
Enter your Heroku credentials.
Email: heroku@memba.org
Password (typing will be hidden):
Could not find an existing public key.
Would you like to generate one? [Yn] Y
Generating new SSH public key.
Uploading SSH public key C:/Users/Jacques-Louis/.ssh/id_rsa.pub... done
Authentication successful.
Since the app has been created from the heroku administration console, configure git:
>git remote add heroku git@heroku.com:expressjs.git
>git remote -v
heroku git@heroku.com:expressjs.git (fetch)
heroku git@heroku.com:expressjs.git (push)
origin https://github.com/jlchereau/Phonegap.Express.git (fetch)
origin https://github.com/jlchereau/Phonegap.Express.git (push)
Upload the API server code from git to heroku:
>git push heroku master
The authenticity of host 'heroku.com (50.19.85.156)' can't be established.
RSA key fingerprint is 8b:48:5e:67:0e:c9:16:47:32:f2:87:0c:1f:c8:60:ad.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'heroku.com,50.19.85.156' (RSA) to the list of known hosts.
...
-----> Caching node_modules directory for future builds
-----> Cleaning up node-gyp and npm artifacts
-----> Building runtime environment
-----> Discovering process types
Procfile declares types -> web
-----> Compressing... done, 7.0MB
-----> Launching... done, v3
http://expressjs.herokuapp.com/ deployed to Heroku
To git@heroku.com:expressjs.git
* [new branch] master -> master
Check the logs:
>heroku logs
We have experienced two issues:
- The API Server was not properly connecting to MongoDB at MongoLab. This was sorted out by adding
NODE_ENV='production'
to heroku config variables. - The API Server would not start at port 80 configured in production.json. Heroku assigns ports dynamically and they cannot be configured. The port needs to be read from the PORT environment variable set by heroku.
Successful deployment can be tested at http://expressjs.herokuapp.com/heartbeat.
Sources:
- https://devcenter.heroku.com/articles/getting-started-with-nodejs
- http://www.letscodejavascript.com/v3/transcripts/lessons_learned/5
- http://niel.delarouviere.com/2012/03/the-really-absolute-beginners-guide-to-host-node-js-on-heroku/
##HTML 5 web app on Google Drive and Dropbox
We have followed simple instructions for Google Drive and Dropbox to publish the www directory AS IS. They can respectively be accessed at:
- http://dl.dropboxusercontent.com/u/32824246/phonegap.express/index.html
- https://www.googledrive.com/host/0B2kgn9WIWu-DLUtwbW5xVFpfdGc/
Clicking the heartbeat button should return "OK" in the console without authenticating.
##Phonegap web app
The Git repository is linked to Phonegap Build and Mobile applications can be downloaded from https://build.phonegap.com/apps/916461/builds
Copyright © 2013-2014 Memba Sarl. All rights reserved.