Watsonbox

Developer's notes.

Fork me on GitHub

Mean.io on Dokku

Here’s how I set up the Mean.io stack for deployment with Dokku.

  • Set up MongoDB on the Dokku host and create a database. I used Jeff Utter’s single container plugin for this.
1
2
3
$ dokku mongodb:start
$ dokku mongodb:create <app> <database>
$ dokku mongodb:link <app> <database>
  • Modify config/env/production.js to use ENV var for MongoDB URL:
config/env/production.js
1
2
3
4
5
6
'use strict';

module.exports = {
  db: process.env.MONGO_URL,

// [REST OF FILE ELIDED]
  • Configure the application to run in the production environment:
1
$ dokku config:set <app> NODE_ENV=production
  • Set the unsafe-perm npm configuration option to allow npm to operate under the root account. More information here. Create .npmrc as follows:
.npmrc
1
unsafe-perm = true
.env
1
BUILDPACK_URL=https://github.com/mbuchetics/heroku-buildpack-nodejs-grunt.git
  • Add Heroku build task without environment to Gruntfile.js since Dokku doesn’t read config during build steps:
Gruntfile.js
1
2
3
4
5
6
7
8
9
  // [REST OF FILE ELIDED]

  // For Heroku users only.
  // Docs: https://github.com/linnovate/mean/wiki/Deploying-on-Heroku
  grunt.registerTask('heroku:production', ['cssmin', 'uglify']);

  // Dokku does not set ENV vars during build steps:
  grunt.registerTask('heroku:', ['cssmin', 'uglify']);
};

Comments