Skip to content

Instantly share code, notes, and snippets.

@letalumil
Forked from fizerkhan/dokku-node-mongo.md
Created October 26, 2015 20:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save letalumil/e92cf3243a5e627723f2 to your computer and use it in GitHub Desktop.
Save letalumil/e92cf3243a5e627723f2 to your computer and use it in GitHub Desktop.
NodeJS and MongoDB app in Dokku with Digital Ocean

Steps:

  1. Create Digital Ocean Droplet with Dokku v0.3.16 on 14.04 image

  2. Login into the droplet and Update local settings.

    sh -c "echo 'LANG=en_US.UTF-8\nLC_ALL=en_US.UTF-8' > /etc/default/locale"
    reboot
  3. Open http://<ip_address_of_droplet> to configure dokku settings.

  4. Add dokku remote to your source code(from your development machine). In below code, app_name can be anything. It should be used when configure the database.

     ```shell
     git remote add dokku dokku@<ip_address_of_droplet>:<app_name>
     git push dokku master
     ```
    
  5. Install MongoDB dokku plugins in Digital Ocean droplet.

     ```shell
     git clone https://github.com/jeffutter/dokku-mongodb-plugin.git /var/lib/dokku/plugins/mongodb
     dokku plugins-install    
     ```
    
  6. Create database

     ```shell
         dokku mongodb:start
         dokku mongodb:create <app_name>
     ```
    
  7. Change your MongoDB url to process.env.MONGO_URL and commit your source code. (You must push app again to take mongodb url) It will print the URL of the app. You can visit the app in browser.

     ```shell
     git push dokku master
     ```
    
  8. You can also view mongodb config

     ```shell
     dokku config <app_name>
     ```
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment