Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to deploy a meteor application to my own server?

How to deploy a meteor application to my own server?

flavour 1: the development and deployment server are the same;

flavour 2: the development server is one (maybe my localhost) and the deployment server is another (maybe a VPS in the cloud);

flavour 3: I want to make a "meteor hosting" domain, just like "meteor.com". Is it possible? How?

Update:

I'm running Ubuntu and I don't want to "demeteorize" the application. Thank you.

like image 470
J. Bruni Avatar asked Jul 12 '13 01:07

J. Bruni


People also ask

How do I run a Meteor server?

You can run it from the root directory of the project or from any subdirectory. Use 'meteor create ' to create a new Meteor project. Commands: run [default] Run this project in local development mode. ... run is the default in case no other command is specified after meteor .


2 Answers

Meteor documentation currently says:

"[...] you need to provide Node.js 0.8 and a MongoDB server. You can then run the application by invoking node, specifying the HTTP port for the application to listen on, and the MongoDB endpoint."


So, among the several ways to install Node.js, I got it up and running following the best advice I found, which is basically unpacking the latest version available directly in the official Node.JS website, already compiled for Linux (64 bits, in my case):

# Does NOT need to be root user:  # create directory mkdir -p ~/.nodes && cd ~/.nodes  # download latest Node.js distribution curl -O http://nodejs.org/dist/v0.10.13/node-v0.10.13-linux-x64.tar.gz  # unpack it tar -xzf node-v0.10.13-linux-x64.tar.gz  # discard it rm node-v0.10.13-linux-x64.tar.gz  # rename unpacked folder mv node-v0.10.13-linux-x64 0.10.13  # create symlink ln -s 0.10.13 current  # add path to PATH export PATH="~/.nodes/current/bin:$PATH"  # check node --version npm --version 


And to install MongoDB, I simply followed the instructions in the MongoDB manual available in the Documentation section of its official website:

# Needs to be root user (apply "sudo" if not at root shell)  apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10 echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | tee /etc/apt/sources.list.d/10gen.list apt-get update apt-get install mongodb-10gen 



The server is ready to run Meteor applications! For deployment, the main "issue" is where the "bundle" operation happens. We need to run meteor bundle command from inside the application source files tree. For example:

cd ~/leaderboard meteor bundle leaderboard.tar.gz 


If the deployment will happen in another server (flavour 2), we need to upload the bundle tar.gz file to it, using sftp, ftp, or any other file transfer method. Once the file is there, we follow both Meteor documentation and the README file which is magically included in the root of the bundle tree:

# unpack the bundle tar -xvzf leaderboard.tar.gz  # discard tar.gz file rm leaderboard.tar.gz  # rebuild native packages pushd bundle/programs/server/node_modules rm -r fibers npm install [email protected] popd  # setup environment variables export MONGO_URL='mongodb://localhost' export ROOT_URL='http://example.com' export PORT=3000  # start the server node main.js 


If the deployment will be in the same server (flavour 1), the bundle tar.gz file is already there, and we don't need to recompile the native packages. (Just jump the corresponding section above.)



Cool! With these steps, I've got the "Leaderboard" example deployed to my custom server, not "meteor.com"... (only to learn and value their services!)

I still have to make it run on port 80 (I plan to use NginX for this), persist environment variables, start Node.JS dettached from terminal, et cetera... I am aware this setup in a "barely naked" one... just the base, the first step, basic foundation stones.

The application has been "manually" deployed, without taking advantage of all meteor deploy command magic features... I've seen people published their "meteor.sh" and "meteoric.sh" and I am following the same path... create a script to emulate the "single command deploy" feature... aware that in the near future all this stuff will be part of the pioneer Meteor explorers only, as it will grow into a whole Galaxy! and most of these issues will be an archaic thing of the past.

Anyway, I am very happy to see how fast the deployed application runs in the cheapest VPS ever, with a surprisingly low latency and almost instant simultaneous updates in several distinct browsers. Fantastic!

Thank you!!!

like image 155
J. Bruni Avatar answered Sep 28 '22 06:09

J. Bruni


Try Meteor Up too

With that you can deploy into any Ubuntu server. This uses meteor build command internally. And used by many for deploying production apps.

I created Meteor Up to allow developers to deploy production quality Meteor apps until Galaxy comes.

like image 25
Arunoda Susiripala Avatar answered Sep 28 '22 06:09

Arunoda Susiripala