Deploying a mean.io app to Heroku

376 views Asked by At

I'm having trouble with the deployment of a mean.io application to Heroku. This post describes the steps I've taken to create the application and to try to deploy it. What am I doing wrong?

First, I start a Mongo daemon process:

$ mongod

Then create a mean.io application:

$ npm install -g mean-cli
$ mean init myNewApp
> app name? myNewApp
> help us improve the mean network? n
> set up first admin user? y
  > email: [email protected]
  > pass: mypassword
$ cd myNewApp
$ mean postinstall
$ npm install
$ bower install
$ gulp

The default mean.io gulp task starts a local webserver, and I'm able to login to the application. The next step is to create a Heroku application:

$ heroku create # this creates https://shrouded-stream-2828.herokuapp.com

And add a MongoDB add-on from compose.io. This was accomplished following these steps:

# In the Heroku web console, select the Heroku application.
# Click edit Add-ons, find Compose MongoDB, and press save. 
# Click on "Compose MongoDB" link, click the "Admin" tab
# Click the "Users" tab, click the "Add user" button, adding the user:
  db.addUser('​meanadmin','​mypassword')
# And hit the "Add user" button to actually add the user.
# Copy the URL from the Overview tab:
mongodb://meanadmin:[email protected]:10479,candidate.3.mongolayer.com:10419/app15307042

With this URL, navigate to /path/to/myNewApp/config/env/production.js in a text editor and replace the values of the "db" property with the Mongo URL above, as in:

db: 'mongodb://' + (process.env.DB_PORT_27017_TCP_ADDR || 'localhost') + '/mean-prod',

becomes...

db: 'mongodb://meanadmin:[email protected]:10479,candidate.3.mongolayer.com:10419/app15307042',

Commit the changes, and push to Heroku:

$ git add .
$ git commit -m 'adding mongodb'
$ git fetch --unshallow
$ git push heroku master
$ heroku open

After a long pause, this results in the following error:

Application Error
An error occurred in the application and your page could not be served. Please try again in a few moments.
If you are the application owner, check your logs for details.

How do I deploy this application to Heroku? I'm not sure if I copied the Mongo URL to the correct place, for instance. What am I doing wrong?

0

There are 0 answers