At Peddle Hawk we build a lot of web and mobile apps and one of our favorite platforms to create apps with is Meteor. After completing our first app we wondered how do we deploy this application? We owned (registered) a domain on HostGator; let’s call it potato.com. We pointed the nameservers on HostGator to Digital Ocean. We eventually used a combination of Meteor Up (mup/mupx), HostGator, Digital Ocean and Compose to deploy the application by doing a lot of little task. That process worked eventually but it was complicated because there are so many things to do but if you miss one step or you’re unable to resolve a problem at one point you fail. Add to that mup is constantly changing and to add SSL it’s another process that you hope won’t leave you butt hurt. There are many guides but the entire process was just a pain. Meteor Galaxy makes this whole process simple but there are some weak points that I want to help people grasp.

TL;DR Galaxy is awesome and everything else works but it’s a pain in the butt. This guide is for people with custom domains but it also caters to meteor.com subdomains.

Key Points Before We Start

Galaxy only hosts so you’ll need to register your domain with a service such as HostGator, NameCheap or GoDaddy. You’ll need to signup for Meteor Galaxy. You should have a domain registered on a service; one preferably where you can edit the DNS without hosting it, such as NameCheap. HostGator doesn’t allow you to edit DNS without hosting on their platform so this guide provides a workaround. Signup for mLab or Compose to connect MongoDB to your deployed app.

Steps to deploy your meteor application using Meteor Galaxy

Summary of the steps before we start:

Step 1: Connect MongoDB Server to app. Step 2: Create settings.json file in main directory and add environment variables Step 3(a): Change DNS settings for domain on registrar that doesn’t allow you (for HostGator) OR Step 3(b): Change DNS settings to point to Meteor Galaxy if possible with registrar Step 4: Deploy application from terminal Step 5: While you wait a little, add SSL certificate to website (extra but useful & free with Galaxy) 🎉 You’re Done 🎉

Step 1: Connect MongoDB Server to app

Summary of this step: You want to setup a mongo database for online use and get a Mongo URI as such:

mongodb://<user>:<password>@dogen.mongohq.com:10023/meteor

This is a quick walk through step one; if you want this step in more detail visit Meteor Tips. Ok, begin by creating an account on Compose and then click ‘Create Deployment’

The Compose MongoDB dashboard

Create a MongoDB deployment: if your Galaxy deployment will be in the East Coast choose US East 1. Else if the Galaxy deployment is in the Europe choose EU West 1.

MongoDB Compose New Deployment Module/Screen

After creating the deployment click ‘Add Database’ and create a new user with a username and password.

Click Admin Gear Icon button and you’ll be given the Mongo URI & Mongo Console. Copy the URI in a text file and replace the user and password part of the URI with your username and password for this database.

mongodb:// <user>:<password> @dogen.mongohq.com:10007/meteor

This URI is going to be used later on and you can access this URI at any point but remember that you need to replace <user> and <password> with your username & password.

Step 2: Environment Variables in settings.json

In the root directory create a file called ‘settings.json’ and insert this code directly (no added code necessary).

{

“galaxy.meteor.com”: {

“env”: {

“ROOT_URL”: “[YOUR APP URL]”,

“MONGO_URL”: “[YOUR MONGODB URI]”

}

}

}

In ROOT_URL insert your domain such as http://www.potato.com notice the www and the http:// . The www is important for so many reasons 1 reason is that it makes things sooooo much easier. Plus, in the future you might add subdomains and don’t worry I’m going to make the root domain ( http://potato.com ) route to www .

You can also deploy to appname.meteorapp.com where appname could be whatever is available.

In MONGO_URL insert your Mongo URI which we got from Step 1.

Step 3(a): Change DNS settings for domain on registrar that doesn’t allow you (for HostGator)

Skip to 3(b) if you can change your DNS with your registrar

If your domain is registered on a service like HostGator you can’t change the DNS settings from within HostGator to point to your app without hosting it on HostGator. So here’s the solution to deploy your meteor app on Galaxy while keeping your domain registered on HostGator:

Create an account on NameCheap. Visit the FreeDNS page and enter your domain in the search bar.

Manage the DNS of your domain with FreeDNS

3. Click the add to cart icon then click ‘Set up DNS’ button.

4. NameCheap will give you 5 values such as this: freedns1.registrar-servers.com to assign to your nameservers on your domain registrar (HostGator in our case).

NameCheap FreeDNS Result

5. Go to where you Manage your domain on your domain registrar and change the nameservers to the value you got from NameCheap.

Change HostGator nameservers to point to NameCheap

6. You have to wait a little (about 30 mins) but if you go to your NameCheap dashboard you will find your domain and the pending status. After the domain management becomes available. Click ‘Advanced DNS’ and add a CNAME record like below.

NameCheap FreeDNS dashboard

Set the host to www and give it a value of galaxy-ingress.meteor.com except if your Galaxy server is in Europe then give it a value of eu-west-1.galaxy-ingress.meteor.com

To redirect the root domain ( http://potato.com ) add a URL Redirect Record with a host value of @ and a value of your www domain such as http://www.potato.com

Step3(b): Change DNS settings to point to Meteor Galaxy if possible with registrar

Skip this step if you did Step 3(a); otherwise continue:

If you can change your DNS settings without hosting it on your registrar do so by adding a CNAME with host as www and value of your domain with subdomain www attached. You can also route the root domain to www by adding a URL Redirect as seen below:

NameCheap FreeDNS dashboard

The @ represents the root domain such as http://potato.com

Step 4: Deploy application from terminal

Mac/Linux:

Open the terminal in the root directory of your meteor app and enter the following to deploy your application:

DEPLOY_HOSTNAME=galaxy.meteor.com meteor deploy www.potato.com — settings settings.json

where www.potato.com is replaced with your domain name but with the www . If your server is on the East Coast you can be more specific in deploying by changing the DEPLOY_HOSTNAME to DEPLOY_HOSTNAME=us-east-1.galaxy-deploy.meteor.com and the same goes for Europe.

Windows:

$ SET DEPLOY_HOSTNAME=galaxy.meteor.com $ meteor deploy www.potato.com --settings settings.json

where www.potato.com is replaced with your domain name but with the www . If your server is on the East Coast you can be more specific in deploying by changing the DEPLOY_HOSTNAME to DEPLOY_HOSTNAME=us-east-1.galaxy-deploy.meteor.com and the same goes for Europe.

Step 5: Wait A Little. Add SSL certificate to website (extra)

Your website should work now (not immediately) but you need to wait a little for your DNS settings to propagate. If you used the force-ssl package the website won’t work because you need to add an SSL certificate which is perfect because Galaxy offers free SSL that auto-renews.

Go to:

Galaxy Dashboard > App > Settings Tab > Scroll to ‘Domain & Encryption Section’ > Click Domain > Generate Certificate > You’re done

Domain in your Galaxy Dashboard

Generate SSL Certificate Meteor Galaxy

🎉 You’re Done 🎉

The process is so simple I love it so much I’m gonna cry 😂 I hope this guide was useful. I would love constructive criticism by messaging me or emailing me at adarwish@peddlehawk.com

Peddle Hawk wants to build your next app! Give us a call at 301.200.2868 or email us and we’ll discuss your project. At Peddle Hawk we take a personal interest in your success and we will work with you constantly, so give us a call.

Credits: