The AppFog Node.js Jumpstart is a sample application that can be used to get started quickly with a new Node.js web application on AppFog.
To get started, copy the contents of this repo to a new source code repository that you have edit privileges to. Clone that repository and login to AppFog. To deploy the application, run the following from the top-level project directory:
$ cf push
Since the manifest.yml file sets the name of the application to ${random-word}
, the name of the application will be generated during the deployment process. Here is example output of the application deployment using cf push
:
cf push
Using manifest file /Users/demo/node/manifest.yml
Creating app ascitic-flavopurpurin in org DEMO / space Dev as Demouser...
OK
Creating route ascitic-flavopurpurin.useast.appfog.ctl.io...
OK
Binding ascitic-flavopurpurin.useast.appfog.ctl.io to ascitic-flavopurpurin...
OK
Uploading ascitic-flavopurpurin...
Uploading app files from: /Users/demo/node
Uploading 27.8K, 7 files
Done uploading
OK
Starting app ascitic-flavopurpurin in org DEMO / space Dev as Demouser...
-----> Downloaded app package (12K)
-------> Buildpack version 1.3.1
Node.js Buildpack v64
-----> Reading application state
package.json...
build directory...
cache directory...
environment variables...
Node engine range: 0.10.25
Npm engine: 2.11.1
Start mechanism: server.js
node_modules source: package.json
node_modules cached: false
NPM_CONFIG_PRODUCTION=true
NODE_MODULES_CACHE=true
Downloading and installing node 0.10.25...
Downloading and installing npm 2.11.1 (replacing version 1.3.24)...
-----> Building dependencies
Installing node modules
npm WARN package.json [email protected] No repository field.
[email protected] node_modules/express
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected] ([email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected])
└── [email protected] ([email protected], [email protected])
-----> Checking startup method
No Procfile; Adding 'web: node server.js' to new Procfile
web: node server.js
-----> Finalizing build
Creating runtime environment
Cleaning previous cache
Caching results for future builds
-----> Build succeeded!
[email protected] /tmp/staged/app
└── [email protected]
-----> Uploading droplet (6.9M)
1 of 1 instances running
App started
OK
App ascitic-flavopurpurin was started using this command `node server.js`
Showing health and status for app ascitic-flavopurpurin in org DEMO / space Dev as Demouser...
OK
requested state: started
instances: 1/1
usage: 256M x 1 instances
urls: ascitic-flavopurpurin.useast.appfog.ctl.io
last uploaded: Thu Jun 11 17:24:09 UTC 2015
stack: cflinuxfs2
state since cpu memory disk details
#0 running 2015-06-11 02:24:45 PM 0.0% 22.4M of 256M 32M of 1G
Once the application is running, copy the value for urls:
, in the case above ascitic-flavopurpurin.useast.appfog.ctl.io
, and go to that URL in a browser. You should see a page that looks like:
- Web page:
public/index.html
. - Application Controller:
server.js
.
A very useful read is here. This will give you an overview of the general process used to deploy Node.js applications to AppFog.
As a start point, you can modify the file server.js
as needed.
A very good place to start with Nodejs is here.
If you are more experienced, this can be useful for you.