Meteor app deploy to Amazon / Azure / On-premise

Meteor is pretty popular modern framework, so let’s see how can be meteor app deployed to Amazon / Azure / On-premise (actually we need only one or more linux boxes).

Let’s start & create simple meteor app called clock.

To do this we’ll need to download & install meteor:

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

 

And now we can create sample app:

meteor create --example clock

 

We can test it by entering directory with app and executing

meteor run

 

Screen Shot 2015-12-22 at 17.55.35

Great, our app works locally, and now it’s time to deploy it to production!

I’ll use Amazon for this demo where I’ve created two load balanced instances running Ubuntu 14.04.

We’ll deploy meteor app using MUP and to run it we need to install node & npm from here https://nodejs.org/en/

Now we’re able to install MUP using NMP:

sudo npm install -g mup

 

Now we need to execute mup init in project folder. After this, two files will be added to project folder:

Screenshot at Dec 22 18-09-52

 

My settings.json looks like this:

{
  // Server authentication info
  "servers": [
    {
      "host": "ec2-54-213-80-1.us-west-2.compute.amazonaws.com",
      "username": "ubuntu",
      //"password": "password"
      // or pem file (ssh based authentication)
      "pem": "~/aws-lab.pem"
    },
    {
      "host": "ec2-54-213-80-6.us-west-2.compute.amazonaws.com",
      "username": "ubuntu",
      //"password": "password"
      // or pem file (ssh based authentication)
      "pem": "~/aws-lab.pem"
    }
    
  ],

  // Install MongoDB in the server, does not destroy local MongoDB on future setup
  "setupMongo": true,

  // WARNING: Node.js is required! Only skip if you already have Node.js installed on server.
  "setupNode": true,

  // WARNING: If nodeVersion omitted will setup 0.10.36 by default. Do not use v, only version number.
  "nodeVersion": "0.10.36",

  // Install PhantomJS in the server
  "setupPhantom": true,

  // Show a progress bar during the upload of the bundle to the server. 
  // Might cause an error in some rare cases if set to true, for instance in Shippable CI
  "enableUploadProgressBar": true,

  // Application name (No spaces)
  "appName": "meteorapp1",

  // Location of app (local directory)
  "app": ".",

  // Configure environment
  "env": {
    "ROOT_URL": "http://meteorapp1.kagarlickij.com"
  },

  // Meteor Up checks if the app comes online just after the deployment
  // before mup checks that, it will wait for no. of seconds configured below
  "deployCheckWaitTime": 30
}

Let’s try to setup server, to do it we’ll execute mup setup:

Screenshot at Dec 22 18-31-48

And now we can deploy executing mup deploy. Errors!

Screenshot at Dec 22 18-35-03

Let’s see details executing mup logs -f :

Screenshot at Dec 22 18-36-53

It seems to be easy to fix:

Screenshot at Dec 22 18-37-56

And now we need to run mup setup again to install newer version of node and than rum mup deploy to get result:

Screenshot at Dec 22 18-44-16

So our app is now running in load balanced cluster:

Screenshot at Dec 22 18-46-18

 

And last point — probably you’ll wish don’t store database on instances, in this case just use MONGO_URL string in env block.

Pin It

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *

Этот сайт использует Akismet для борьбы со спамом. Узнайте, как обрабатываются ваши данные комментариев.