Deploying Your Meteor-Postgres Project on a Linux VM

In order to get this up and running we first need to set up your PosgreSQL database please refer to this step by step post. Next let’s install MongoDB. You won’t need to use it, but Meteor requires it upon launch. Take a look at Mongo’s official documentation site for detailed instructions.

Next let’s install Node:

sudo apt-get update
sudo apt-get install nodejs
sudo npm install npm –g

Now let’s install Meteor:

curl https://install.meteor.com/ | sh

Next comes git (if you are looking to set up continuous integration you would also be adding those tools here):

sudo apt-get install git

Once we have git let’s clone your repo. For this you will need to get your repos HTTPS clone URL.

git

git clone https://< HTTPS clone URL>

In order to be able to access the website we will need to open up the website’s endpoints. Here’s a video demo on how to do it in Azure. Meteor’s default port for development is port 3000 so make sure to open it. Now let’s run the project to make sure it’s working:

meteor

You now should be able to navigate to your website www.yourwebsite.com:3000/ and access your application. We now need to convert the app to a Node application. The first step is to install Node-Gyp:

npm install -g node-gyp

Once node-gyp is installed we can install demeteorizer:

sudo npm install demeteorizer -g

This will save the new Node version of your application in a .demeteorized folder. So you will need to cd into that folder:

cd .demeteorized

Once in this folder let’s first test the Node version of the app to make sure it still works. First we need to run an NPM install to make sure all the dependencies have been installed.

npm install

Once the dependencies have been installed, let’s test it. You can either set the env variables below or you can just provide them the application as you call it:

sudo MONGO_URL=mongodb://localhost:27017/test PORT=3000 ROOT_URL=http://localhost:3000/ POSTGRES=postgres://<user>:<password>@localhost/<database> node main.js

Now that we know that the Node version is also working, let’s install the Forever library.

npm install forever -g

Now you are ready to run your project as a daemon. I have been having issues running demeteorized applications on port 80, so I recommend setting the internal port to 3000 and linking the external port 80 to the internal port 3000.