Deploying a MEAN Stack Onto Google Compute Engine

Gone are the days where a product team used to spend a considerable amount of time to build a basic web application.  Say Hi to MEAN! If you are familiar with LAMP/WAMP stacks, you could consider MEAN as a complete stack based on JavaScript. In fact, MEAN represents: MongoDB,  Express, AngularJS and NodeJS:

  • Mongo DB – The Leading NoSQL database
  • Express JS – The Web Application Framework
  • Angular JS  – The HTML enhanced Web Apps
  • Node JS  – a platform to build scalable network applications

With MEAN, you could have your web application running in less than 10 minutes.
Deploying a MEAN based application on AWS or Azure is quite straightforward as there are ready-made templates from 3rd party vendors like Bitnami. Neverthelss, it’s not that easy on Google Compute Engine, given that there are no built-in images for that platform.
In this post, I will describe the rationale in choosing MEAN stack over others, and 10 Steps to deploy a MEAN stack on Google Compute Engine
We have had rich experience in creating many enterprise application using J2EE, Python, .Net and other technologies. You may wonder why on earth we chose MEAN! Let me list down the reasons:

  • JavaScript is often considered to be front end technology. Actually, everything can be written in JavaScript and there are more and more examples of effective server-side usage of Javascript.
  • We want to use an open source language, with strong community support and with a quick development cycle. We had many options, like Python, Ruby and Angular + Node. We had had to learn different languages for UI and Backend in case of Python and Ruby. But Javascript is used in both Angular and Node.
  • AngularJS supports a native MVC framework and promotes Test Driven Development with the Karma/Mocha test framework. AngularJS UI renders on all kinds of browsers  supporting HTML5 supported.
  • ExpressJS is a good web framework on top of NodeJS. It provides us hooks to easily develop a scalable application server.

So, all this considered, here are the steps to deploy a MEAN stack on GCP
Step 1: Sign up for Google Compute Engine, or sign in if you have an account already
Step 2: Create a project or Go into your existing Project
Step 3: Go to Google Compute Engine -> VM Instances
Step 4: Create a CentOS based VM Instance
create_vm
Step 5: Once the VM is up, SSH into the VM Instance
gcutil --service_version="v1" --project="##your_project" ssh --zone="asia-east1-a" "my-mean-stack"
Step 6: Download NodeJS and Place it on your path:
wget http://nodejs.org/dist/v0.10.28/node-v0.10.28-linux-x64.tar.gz
tar xvfz node-v0.10.28-linux-x64.tar.gz
mv node-v0.10.28-linux-x64 /usr/share/

Step 7: Install MongoDB and git:
sudo yum install mongodb-org git
Step 8: Deploy meanio module
$sudo npm install -g meanio
$mean init my-mean-app
Cloning branch: master into destination folder: my-mean-app
Initialized empty Git repository in /home/user/my-mean-app/.git/
....
install dependencies:
$ cd my-mean-app && npm install

Step 9: Start your server
$ grunt
Running "clean:0" (clean) task

Running "jshint:all" (jshint) task
>> 41 files lint free.

Running "csslint:src" (csslint) task
>> 3 files lint free.

Running "concurrent:tasks" (concurrent) task
Running "watch" task
Waiting...
Running "nodemon:dev" (nodemon) task
[nodemon] v1.0.20
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node --debug server.js`
debugger listening on port 5858
js-bson: Failed to load c++ bson extension, using pure JS version
Mean app started on port 3000 (development)
Failed to load c++ bson extension, using pure JS version

Step 10: Open up port 3000 in your Google Compute Network Firewall

Add Firewall Rule
Add Firewall Rule

Thats it! Launch your browser and point to http://your_external_ip:3000/. Your web app is up and running!
 
 

Related Posts

— November 21, 2018

Google Cloud Certification: Preparation and Prerequisites

Google Cloud Platform (GCP) has evolved from being a niche player to a serious competitor to Amazon Web Services and Microsoft Azure. In 2018, research firm Gartner placed Google in the Leaders quadrant in its Magic Quadrant for Cloud Infrastructure as a Service for the first time. In t...

Read more
  • AWS
  • Azure
  • Google Cloud
— October 30, 2018

Azure Stack Use Cases and Applications

This is the second of a two-part series covering Azure Stack. Our first post provided an introduction to Azure Stack. Why would your organization consider using Azure Stack? What are the key differences between Azure Stack and Microsoft Azure? In this post, we'll begin to answer bot...

Read more
  • Azure
  • Hybrid Cloud
  • Virtualization
— October 3, 2018

Highlights from Microsoft Ignite 2018

Microsoft Ignite 2018 was a big success. Over 26,000 people attended Microsoft’s flagship conference for IT professionals in sunny Orlando, Florida. As usual, Microsoft made a huge number of announcements, ranging from minor to major in importance. To save you the trouble of sifting thr...

Read more
  • Azure
  • Ignite
— September 20, 2018

Planning for Microsoft Ignite 2018 Sessions: What Not to Miss

Cloud Academy is proud to be a sponsor of the Microsoft Ignite Conference to be held September 24 - 28 in Orlando, Florida. This is Microsoft’s biggest event of the year and is a great way to stay up to date on how to get the most from Microsoft’s products. In this post, I’ll help you p...

Read more
  • Azure
— September 18, 2018

How to Optimize Cloud Costs with Spot Instances: New on Cloud Academy

One of the main promises of cloud computing is access to nearly endless capacity. However, it doesn’t come cheap. With the introduction of Spot Instances for Amazon Web Services’ Elastic Compute Cloud (AWS EC2) in 2009, spot instances have been a way for major cloud providers to sell sp...

Read more
  • AWS
  • Azure
  • Google Cloud
— August 23, 2018

What are the Benefits of Machine Learning in the Cloud?

A Comparison of Machine Learning Services on AWS, Azure, and Google CloudArtificial intelligence and machine learning are steadily making their way into enterprise applications in areas such as customer support, fraud detection, and business intelligence. There is every reason to beli...

Read more
  • AWS
  • Azure
  • Google Cloud
  • Machine Learning
— July 5, 2018

How Does Azure Encrypt Data?

In on-premises environments, data security is typically a siloed activity, with a company's security team telling the internal technology groups (server administration, database, networking, and so on) what needs to be protected against intrusion.This approach is absolutely a bad...

Read more
  • Azure
— June 26, 2018

Disadvantages of Cloud Computing

If you want to deliver digital services of any kind, you’ll need to compute resources including CPU, memory, storage, and network connectivity. Which resources you choose for your delivery, cloud-based or local, is up to you. But you’ll definitely want to do your homework first.Cloud ...

Read more
  • AWS
  • Azure
  • Cloud Computing
  • Google Cloud
Albert Qian
— June 19, 2018

Preparing for the Microsoft Azure 70-535 Exam

The credibility of Microsoft Azure continues to grow in the first quarter of 2018 with an increasing number of enterprises migrating their workloads, resulting in a jump for Azure from 10% to 13% in market share. Most organizations will find that simply “lifting and shifting” applicatio...

Read more
  • Azure
  • Compute
  • Database
  • Security
— April 12, 2018

Azure Migration Strategy: A Checklist to Get Started

By now, you’ve heard it many times and from many sources: cloud technology is the future of IT. If your organization isn’t already running critical workloads on a cloud platform (and, if your career isn’t cloud-focused), you’re running the very real risk of being overtaken by nimbler co...

Read more
  • Azure
— March 2, 2018

Three Must-Use Azure Security Services

Keeping your cloud environment safe continues to be the top priority for the enterprise, followed by spending, according to RightScale’s 2018 State of the Cloud report.The safety of your cloud environment—and the data and applications that your business runs on—depends on how well you...

Read more
  • Azure
  • Security
— February 15, 2018

Is Multi-Cloud a Solution for High Availability?

With the average cost of downtime estimated at $8,850 per minute, businesses can’t afford to risk system failure. Full access to services and data anytime, anywhere is one of the main benefits of cloud computing.By design, many of the core services with the public cloud and its underl...

Read more
  • AWS
  • Azure
  • Cloud Adoption
  • Google Cloud