Deploy Meteor 1.3 to DigitalOcean

Published on 08 June 2016

There are several guides for deploying Meteor to DigitalOcean, but with the release of 1.3 earlier this year, some of those guides needed a few adjustments. So these are the steps I used to deploy Meteor 1.3 to DigitalOcean with the following stack:

  • Meteor 1.3 & Mup
  • MongoDB
  • nginx
  • Ubuntu

Why this particular combination? That's not the purpose of this post, but I have my reasons and, if you're reading this, you'll have yours too. I will say this about DigitalOcean though, it had a decent price-point for its offering, and it was easy to set up[1], I also learned after I signed up with them that they have a referral program, so that's what's linked, because why not.

Also, DigitalOcean seem pretty fantastic with their documentation, so if you need to figure something out, you'll probably find some answers in their knowledge-base. This guide refers to several of their docs, because clearly they'll know their infrastructure better than I do.

This guide also assumes you are comfortable with basic to intermediate system administration tasks and command-line interfaces.

Step 1: Ubuntu

Assuming you already have a Droplet, you can use DigitalOcean's detailed guide for setting up Ubuntu 16.04[2]. Definitely follow their recommendations for setting up SSH key authentication.

Note: Should you find performance somewhat lacking, adding swap is an option, however DigitalOcean recommends against doing this for hosts that use SSD storage, and suggests upgrading the Droplet instead. If you're using a remote MongoDB server or service, you may not need this.

Step 2: nginx

Again, there's a guide for that[3].

If you have a custom domain, you will need to have added an A record that points to the IP of your Droplet through your domain registrar. Your registrar should have guides for this if you're not sure how to make this happen.

Once nginx is set up and running, you will also need to add a configuration file for your new site and domain. The Mup wiki has a template that you can use. Don't forget to restart your nginx service so that your new configuration takes effect.

Step 3: Mup

A few of the other guides will refer you to MupX, however, at time of writing, this does not appear to be compatible with Meteor 1.3 (yet), so you will need to use Kadira's version of Meteor Up. I found the README was adequate for setting this up, and it will also automatically set up Node and local MongoDB for you on your Droplet.

If you're using ssh key authentication, your Mup configuration will need to use the pem parameter and not password, but if you attached a password to your key, this may not work.

Also for reference, when you run mup deploy, this process can take some time as everything is being bundled up then copied over to your Droplet. Go make yourself a cup of tea or something while this happens.

Done!

And that's it. In under an hour you should be able to access your Meteor 1.3 application at your Droplet's IP or your custom domain.

As a final recommendation, DigitalOcean also has a few additional guides on securing your Droplet based on your operating system, so I would take a look at these as well, lest some script-kiddie decide to ruin your day for the lulz.

Troubleshooting

There are times when a deploy will fail, even though it seems to work fine on your local. Delete your node_modules directory and run npm install again to make sure everything still runs as expected locally, then try to deploy again.


[1] When I was looking for services to which to deploy a prototype, I tried OpenShift and Heroku, and the setup just didn't go as smoothly or reliably as DigitalOcean. For production, there are a few popular services for this type of stack, but your choice will depend on your business needs.

[2] There is also a guide for setting up Ubuntu 14.04 (and adding swap, if necessary). If you are using this guide instead, I would still follow step 5 of the 16.04 guide to disable password authentication after setting up SSH keys.

[3] And the guide for Ubuntu 14.04.