Meteor on Digital Ocean

Posted by {"display_name"=>"greg", "login"=>"greg", "email"=>"greg@udon.org", "url"=>""} on February 11, 2016 · 3 mins read

This is a cheatsheet on deploying a Meteor app to an Ubuntu droplet on Digital Ocean using Meteor Up.

Setup Digital Ocean Droplet

Login to your Digital Ocean account and create a droplet. I'm going to choose the latest Ubuntu distribution and a 512MB server.

Upload your SSH key, give your droplet a name and choose Create.

Within a few minutes your droplet should be created and you'll be assigned an IP address. If you're using an SSH key, then let's ssh in using the key:

ssh -i ~/.ssh/mykey.pub root@1.1.1.1

Install Meteor Up

sudo npm install -g mup

Initialize MUP

mup init

Create mup.json File

Here's an example:

{
  "servers": [// Server authentication info
    {
      "host": "myhost.domain",
      "username": "root"
      //"password": "mypass"
      //"pem": "~/.ssh/id_rsa"
    }
  ],
  "setupMongo": true,
  "setupNode": true,
  "nodeVersion": "0.10.40",
  "setupPhantom" true,
  "enableUploadProgressBar": true,
  "appName": "sdnet",  // appName no spaces
  "app": ".",
  "env": {  // Configure environment
    "PORT": "80",
    "ROOT_URL": "http://myhost.domain"
  },
  "deployCheckWaitTime": 15
}

Remote MongoDB

You can also specify a Remote MongoDB by adding a line similar to this in the env section:

mongodb://username:password@mongodb.test.com:27017/dbname

It's a good idea to test the remote access from your server to make sure you can connect using this command:

mongo mongodb.test.com:27017/dbname -u username -p password

MUP & SSH

To use MUP with ssh there are a few additional steps described in more detail here.

Make sure the pem field is removed from your mup.json file.

Start an ssh agent.

eval $(ssh-agent)

Add the private key:

ssh-add ~/.ssh/mykey

List the added keys:

ssh-add -l

Configure Remote Server

mup setup

Deploy!

mup deploy

If there are errors, you can view the logs with the command:

mup logs -f

Misc MUP Commands

Reconfigure the server based on changes in the mup.json file:

mup reconfig

Start, stop or restart the app:

mup start
mup stop
mup restart

Update mup to the latest version:

npm update mup -g

Debug MUP Issues

On an Ubuntu server your application is installed in the directory:

/opt/<appName>/current/bundle/programs/server/app

To get debug output, enter the following on the command line. This example shows debugging the deploy option but it could be another option.

DEBUG=* mup deploy

You can tail the logfile like this:

mup logs --tail=50

Remove MUP Deployed App

There isn't a command option to remove a deployed app but this Github issue describes the manual steps you can take to remove an app.

First stop the app:

mup stop

Then connect to the server and do these commands:

sudo rm -rf /opt/<appName>

Remove Mongo if you want:

sudo apt-get remove mongodb