Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to deploy a MeteorJS app to Windows Azure? [closed]

Tags:

meteor

azure

How does one deploy a production MeteorJS app to Windows Azure?

like image 310
Harry Love Avatar asked Jan 10 '13 20:01

Harry Love


2 Answers

Yes it is. See http://www.meteorpedia.com/read/Deploying_to_a_PaaS

In most cases this is as simple as using "meteor bundle", demeteorizer, and then uploading the resulting files with your PaaS provider's CLI deploy tool.

Demeteorizer wraps and extends Meteor’s bundle command by creating something that more closely resembles a standard looking Node.js application, complete with a package.json file for dependency management.

$ cd /my/meteor/app
$ demeteorizer -o /my/node/app
$ cd /my/node/app
$ npm install
$ export MONGO_URL='mongodb://user:password@host:port/databasename?autoReconnect=true&connectTimeout=60000'
$ export PORT=8080
$ forever start main.js

Forever keeps your app running after a disconnect or crash, but not a reboot unless you manually add a boot entry.

The whole deploy is much easier using Meteor Up instead. Or maybe mups, though that doesn't even have updated docs.

To run a Meteor app in an Azure web app:

Azure Web App 
Python 2.7
Websockets ON (optional)
WEBSITE_NODE_DEFAULT_VERSION 0.10.32 (default)
ROOT_URL http://webapp.azurewebsites.net
MONGO_URL mongodb://username:[email protected]:36648/dbname (For advanced apps. Request log should say if you need it.)

Dev Machine
Install Visual Studio Community 2015
Install Node 0.12.6
Install Meteor MSI

app> demeteorizer -o ..\app-dem
app-dem\programs\server\packages\webapp.js change .PORT line to "var localPort = process.env.PORT"
app-dem\package.json change "node": "0.10.36" to "node": "0.12.6"
app-dem> npm install 
app-dem> git init
app-dem> git add -A .
app-dem> git commit -m "version 1.0 demeteorized Meteor + tweaks"
app-dem> git remote add azure https://[email protected]:443/webapp.git
app-dem> git config http.postBuffer 52428800
app-dem> git push azure master

Instead of demeteorizer -o, perhaps you could use meteor build and create a package.json in the output root:

{
    "name": "App name",
    "version": "0.0.1",
    "main": "main.js",
    "scripts": {
        "start": "node main.js"
    },
    "engines": {
        "node": "0.12.6"
    }
}

If bcrypt doesn't compile, make sure to use a more recent version:

    "dependencies": {
        "bcrypt": "https://registry.npmjs.org/bcrypt/-/bcrypt-0.8.4.tgz"
    }
like image 142
Cees Timmerman Avatar answered Nov 07 '22 20:11

Cees Timmerman


Before starting make sure your have install'd a 32 bit version of nodejs and have run "npm -g install fibers" on your windows build machine. Default nodejs on azure is running 32 bit only!

Note: this will not work if you'r using for example the spiderable package which relays on PhantomJS. PhantomJS can not be executed in a webapp on azure?

  1. In your project "meteor build ..\buildOut" and extract the .tar.gz file located in "..\buildOut".
  2. Place/create in "..\buildOut\bundle" a "package.json" containing:
{
    "name": "AppName",
    "version": "0.0.1",
    "main": "main.js",
    "scripts": {
        "start": "node main.js"
    },
    "engines": {
        "node": "0.12.6"
    }
}

Note: Make sure "name" doesn't contain spaces, the deploy on azure will fail.

  1. On your favorite shell, goto "..\buildOut\bundle\programs\server" and run "npm install". This will pre download all the requirements and build them.
  2. Now open the file "..\buildOut\bundle\programs\server\packages\webapp.js" and search for "process.env.PORT".

it looks like this:

var localPort = parseInt(process.env.PORT) || 0;

alter this line into:

var localPort = process.env.PORT || 0;

This is needed so your meteor project can accept a named socket as soon as it runs in node. The function "parseInt" will not let a string go thru, the named socket is a string located in your webapp's environment. This my be done for a reason, a warning here! Now save this change an we are almost done...

  1. Solve the bcrypt issue: Download this file and extract it somewhere: https://registry.npmjs.org/bcrypt/-/bcrypt-0.8.4.tgz Extract it.

Now replace the files located: "..\buildOut\bundle\programs\server\npm\npm-bcrypt\node_modules\bcrypt*"

with the directory's and file's located somewhere: ".\bcrypt-0.8.4\package*"

Now go on the shell in the directory "..\buildOut\bundle\programs\server\npm\npm-bcrypt\node_modules\bcrypt\" and make sure you remove the "node_modules" directory. If the node_modules directory is not removed npm will not build the package for some reason.

Run on the shell "npm install".

Make sure you set the "Environment" variables: "MONGO_URL" and "ROOT_URL" in the portal for you webapp.

If everything worked without an error, you can deploy your app to the git repository on the deployment slot for your webapp. Go to "..\buildOut\bundle" and commit the files there to the deployment slot's repository. This will course the deploy on the deployment slot and create the needed iis configuration file(s).

Now wait a little and your app should fire after some time... Your app should be running and you can access it on the *.azuresites.net

Thanks to all that made this possible.

like image 21
Teunis Martijn Vaandering Avatar answered Nov 07 '22 20:11

Teunis Martijn Vaandering