Skip to content
This repository was archived by the owner on Aug 30, 2021. It is now read-only.

Commit efd3ee4

Browse files
committed
Initial support for deploying MEANJS to Cloud Foundry
1 parent 8104c98 commit efd3ee4

File tree

6 files changed

+153
-1
lines changed

6 files changed

+153
-1
lines changed

.cfignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# List of files and directories to ignore when deploying to Cloud Foundry
2+
.DS_Store
3+
.nodemonignore
4+
.sass-cache/
5+
npm-debug.log
6+
node_modules/
7+
public/lib
8+
app/tests/coverage/
9+
.bower-*/
10+
.idea/

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,40 @@ In the docs we'll try to explain both general concepts of MEAN components and gi
171171
## Live Example
172172
Browse the live MEAN.JS example on [http://meanjs.herokuapp.com](http://meanjs.herokuapp.com).
173173

174+
## Deploying To Cloud Foundry
175+
176+
Cloud Foundry is an open source platform-as-a-service (PaaS). The MEANJS project
177+
can easily be deployed to any Cloud Foundry instance. The easiest way to deploy the
178+
MEANJS project to Cloud Foundry is to use a public hosted instance. The two most popular
179+
instances are [Pivotal Web Services](https://run.pivotal.io/) and
180+
[IBM Bluemix](https://bluemix.net). Both provide free trials and support pay-as-you-go models
181+
for hosting applications in the cloud. After you have an account follow the below steps to
182+
deploy MEANJS.
183+
184+
* Install the [Cloud Foundry command line tools](http://docs.cloudfoundry.org/devguide/installcf/install-go-cli.html).
185+
* Now you need to log into Cloud Foundry from the Cloud Foundry command line.
186+
* If you are using Pivotal Web Services run `$ cf login -a api.run.pivotal.io`.
187+
* If you are using IBM Bluemix run `$ cf login -a api.ng.bluemix.net`.
188+
* Create a Mongo DB service, IBM Bluemix and Pivotal Web Services offer a free MongoLabs service.
189+
* `$ cf create-service mongolab sandbox mean-mongo`
190+
* Clone the GitHub repo for MEANJS if you have not already done so
191+
* `$ git clone https://github.com/meanjs/mean.git && cd mean`
192+
* Run `$ npm install`
193+
* Run the Grunt Build task to build the optimized JavaScript and CSS files
194+
* `$ grunt build`
195+
* Deploy MEANJS to Cloud Foundry
196+
* `$ cf push`
197+
198+
After `cf push` completes you will see the URL to your running MEANJS application
199+
(your URL will be different).
200+
201+
requested state: started
202+
instances: 1/1
203+
usage: 128M x 1 instances
204+
urls: mean-humbler-frappa.mybluemix.net
205+
206+
Open your browser and go to that URL and your should see your MEANJS app running!
207+
174208
## Credits
175209
Inspired by the great work of [Madhusudhan Srinivasa](https://github.com/madhums/)
176210
The MEAN name was coined by [Valeri Karpov](http://blog.mongodb.org/post/49262866911/the-mean-stack-mongodb-expressjs-angularjs-and)

config/assets/cloud-foundry.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
'use strict';
2+
3+
module.exports = {
4+
client: {
5+
lib: {
6+
css: [
7+
'public/lib/bootstrap/dist/css/bootstrap.min.css',
8+
'public/lib/bootstrap/dist/css/bootstrap-theme.min.css',
9+
],
10+
js: [
11+
'public/lib/angular/angular.min.js',
12+
'public/lib/angular-resource/angular-resource.min.js',
13+
'public/lib/angular-animate/angular-animate.min.js',
14+
'public/lib/angular-ui-router/release/angular-ui-router.min.js',
15+
'public/lib/angular-ui-utils/ui-utils.min.js',
16+
'public/lib/angular-bootstrap/ui-bootstrap-tpls.min.js',
17+
'public/lib/angular-file-upload/angular-file-upload.min.js'
18+
]
19+
},
20+
css: 'public/dist/application.min.css',
21+
js: 'public/dist/application.min.js'
22+
}
23+
};

config/env/cloud-foundry.js

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
'use strict';
2+
3+
var cfenv = require('cfenv'),
4+
appEnv = cfenv.getAppEnv(),
5+
cfMongoUrl = appEnv.getService('mean-mongo') ?
6+
appEnv.getService('mean-mongo').credentials.uri : undefined;
7+
8+
var getCred = function(serviceName, credProp) {
9+
return appEnv.getService(serviceName) ?
10+
appEnv.getService(serviceName).credentials[credProp] : undefined;
11+
};
12+
13+
module.exports = {
14+
port: appEnv.port,
15+
db: {
16+
uri: cfMongoUrl,
17+
options: {
18+
user: '',
19+
pass: ''
20+
}
21+
},
22+
log: {
23+
// Can specify one of 'combined', 'common', 'dev', 'short', 'tiny'
24+
format: 'combined',
25+
// Stream defaults to process.stdout
26+
// By default we want logs to go to process.out so the Cloud Foundry Loggregator will collect them
27+
options: {
28+
}
29+
},
30+
facebook: {
31+
clientID: getCred('mean-facebook', 'id') || 'APP_ID',
32+
clientSecret: getCred('mean-facebook', 'secret') || 'APP_SECRET',
33+
callbackURL: '/api/auth/facebook/callback'
34+
},
35+
twitter: {
36+
clientID: getCred('mean-twitter', 'key') || 'CONSUMER_KEY',
37+
clientSecret: getCred('mean-twitter', 'secret') || 'CONSUMER_SECRET',
38+
callbackURL: '/api/auth/twitter/callback'
39+
},
40+
google: {
41+
clientID: getCred('mean-google', 'id') || 'APP_ID',
42+
clientSecret: getCred('mean-google', 'secret') || 'APP_SECRET',
43+
callbackURL: '/api/auth/google/callback'
44+
},
45+
linkedin: {
46+
clientID: getCred('mean-linkedin', 'id') || 'APP_ID',
47+
clientSecret: getCred('mean-linkedin', 'secret') || 'APP_SECRET',
48+
callbackURL: '/api/auth/linkedin/callback'
49+
},
50+
github: {
51+
clientID: getCred('mean-github', 'id') || 'APP_ID',
52+
clientSecret: getCred('mean-github', 'secret') || 'APP_SECRET',
53+
callbackURL: '/api/auth/github/callback'
54+
},
55+
paypal: {
56+
clientID: getCred('mean-paypal', 'id') || 'CLIENT_ID',
57+
clientSecret: getCred('mean-paypal', 'secret') || 'CLIENT_SECRET',
58+
callbackURL: '/api/auth/paypal/callback',
59+
sandbox: false
60+
},
61+
mailer: {
62+
from: getCred('mean-mail', 'from') || 'MAILER_FROM',
63+
options: {
64+
service: getCred('mean-mail', 'service') || 'MAILER_SERVICE_PROVIDER',
65+
auth: {
66+
user: getCred('mean-mail', 'username') || 'MAILER_EMAIL_ID',
67+
pass: getCred('mean-mail', 'password') || 'MAILER_PASSWORD'
68+
}
69+
}
70+
}
71+
};

manifest.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
declared-services:
3+
mean-mongo:
4+
label: mongolab
5+
plan: sandbox
6+
applications:
7+
- name: mean
8+
host: mean-${random-word}
9+
memory: 128M
10+
services:
11+
- mean-mongo
12+
env:
13+
NODE_ENV: cloud-foundry

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@
5757
"serve-favicon": "^2.3.0",
5858
"socket.io": "^1.3.5",
5959
"swig": "^1.4.2",
60-
"validator": "^3.41.2"
60+
"validator": "^3.41.2",
61+
"cfenv": "~1.0.0"
6162
},
6263
"devDependencies": {
6364
"grunt-concurrent": "^2.0.0",

0 commit comments

Comments
 (0)