GithubHelp home page GithubHelp logo

mean's Introduction

MEAN Stack for Quilt.js

The MEAN stack (MongoDB, Express, AngularJS, and node.js) is a popular fullstack JavaScript framework used for web development. Deploying a flexible, multi-node MEAN stack app can be both time consuming and costly, but Quilt simplifies this process. Below, we walk through how to deploy your application in the cloud using Quilt.

Deploying your MEAN stack app with Quilt

This repository already contains all the code needed for deploying the multi-node MEAN stack. The current code deploys a todo app, but we want to change it to deploy our very simple example app, awesome-restaurant-app, located in github.com/luise/awesome-restaurant-app.

To do this, we just have to tweak a single line of code in mean.js

How to

Our app

First, we make sure that our MongoDB connection URI is set to the MONGO_URI environment variable. Note that this is set in our MEAN app code, not the Quilt.js specs:

var mongoose = require('mongoose');
mongoose.connect(process.env.MONGO_URI);

This is already done in the awesome-restaurant-app, but you'll need to do something similar to your own MEAN app before deploying it with Quilt.

For an example, see how server.js in the awesome-restaurant-app uses the URI in config/database.js to connect to MongoDB.

mean.js

The Node constructor called in mean.js takes a string repo which specifies the git repository containing the Node application to deploy. Let's change this URL to point to our restaurant app:

var app = new Node({
  ...
  repo: "https://github.com/luise/awesome-restaurant-app.git",
  ...
});

Finally, before we deploy our MEAN stack, let's set the sshKeys property to be our GitHub username instead of ejj. This way we can ssh into the VMs in our deployment using any ssh key associated with our GitHub profile.

var baseMachine = new Machine({
    ...
    sshKeys: githubKeys("ejj"),
});

If you want to change the characteristics of the VMs, go ahead and modify the relevant properties of the baseMachine object.

Deploy

Now we're ready to deploy our MEAN stack application! If you haven't already worked through Quilt's Getting Started guide guide, now is a good time to check it out and set up Quilt.

When you're set up, run quilt daemon in one shell, and then run quilt run ./mean.js from the mean directory in another shell. If successful, the quilt run command has no output, while the daemon will output logs similar to this:

$ quilt daemon
INFO [Feb 17 16:23:59.181] db.Cluster:
	Cluster-1{}
INFO [Feb 17 16:23:59.184] db.Machine:
	Machine-2{c14105b79bb167a088cf1ae8c9169b51deb6b29f, Master, Amazon us-west-1 m4.large, Disk=32GB}
	Machine-3{89d34da8fde90ce26650c0629f22e2c9e48b8f46, Worker, Amazon us-west-1 m4.large, Disk=32GB}
	...

You can see the status of the system with the command quilt show. The system is fully booted when the STATUSes of all containers are running:

CONTAINER       MACHINE         COMMAND                                 LABELS      STATUS     CREATED               PUBLIC IP
7101084e12ab    89d34da8fde9    node-app:awesome-restaurant-app.git     app         running    About a minute ago
c8e5464625e0    89d34da8fde9    quilt/mongo                             mongo       running    About a minute ago

4d3d6be15985    a2077202355d    haproxy:1.6.4                           hap         running    About a minute ago    54.193.9.14:80
...
Access Web App

We can now access our web app by using the public IP address of the VM hosting a proxy container. The above output from quilt show shows us that we can access the web app at 54.193.9.14.

Now, simply go to http://PROXY_PUBLIC_IP:80 in your browser. As you see, our app is up!

Shut Down VMs

To shut down our application and VMs, run quilt stop, and wait for the message Successfully halted machines. in the quilt daemon output.

More Info

See Quilt for more information.

mean's People

Contributors

ejj avatar kklin avatar luise avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.