DEV Community

Dhruv
Dhruv

Posted on

Deploying your Node.js , mongoDB app on Google Cloud for free

This post focuses on how to deploy your node.js application on Google cloud. Yes it is free, well not technically but you get free $300 credits for a year on a new sign up (yay!).
You’ll need to sign in to your Google Cloud from an existing google account and enter into your console.
Start with creating a new project. Now we can either create a new App Engine instance or a new Compute Engine instance. I’ll be creating a Compute Engine instance.
From the navigation on the left, go to compute engine → VM instances. Create a new VM instance. Fill in the details as per your needs. Although you can only use 3 machine types if you want your whole year to be free.
1) [shared] micro CPU, 0.6GB memory
2) [shared] small CPU, 1.7GB memory
3) CPU, 3.75GB memory
Third option won’t last for whole year though.

Google Cloud CPU

Now you have a machine where you have to deploy your code. SSH your way through.

Things you’ll have to do on your VM now

  • Installing node.js

Install the latest node.js version or any particular version you want. You can follow this guide to install node.js.

  • Installing mongoDB

Install the latest mongoDB version or any particular version you want. You can follow this guide to install mongoDB.

  • Putting code in place

Put your code wherever and however you want to. It’s always better to use git for your projects, shall talk about git and it’s importance in sometime in some other post.

Once you are done with all these things you can run your application. But hold on you still can’t access it from any external source(like your browser). You need to open a port your application is running on.

Opening any port from Google Cloud Console

From the navigation on the left, go to Networking → Firewall Rules.
Create a new firewall rule, fill in the required details and bam you’re up!

Google Cloud Firewall

Source filter for IP range is to specify from which all IPs you want it to be accessible, in case of any write 0.0.0.0/0.
Congrats you’ve successfully deployed your application on Google Cloud.

Originally published on medium.

Top comments (0)