Deploying your app on the google ecosystem — part 2

Sagar Biswas
3 min readJul 9, 2020

--

Source of Image

Great,so you have a VM instance setup on GCP and can ssh into it via your local terminal. If you are behind this step or need some guidance on how to create your first VM instance and free trial information on GCP refer to this post.

The next steps would be to get a domain name, setup a load balancer to route to our desired landing page and make sure that our firewall rules are edited to accept HTTP requests (by default this is turned off).

Getting your domain name

There are multiple domain registration services online: Godaddy and Google domains. AWS also has a domain registration service. For the sake of our tutorial we will using google domains for our registration as we plan to deploy our app on GCP, being on the same source reduces multiple roadblocks and verifications along the way. NOTE : You can use any domain registration and with a few tweaks everything will work just fine.

To buy a domain name head to : https://domains.google.com/m/registrar/search

Search for the domain name and proceed to finish the purchase.

PRO TIP: If you proceed to purchase G SUITE to get a swanky official email id for your domain name, you can keep your admin and primary email to something like enquiries@xyz.com or contact@xyz.com. This is because every user on G SUITE is a paid service and by keeping your admin mail as something you would use as external contact point saves you at least a couple of bucks every month.

If you’ve gone through the above steps to get your domain name and configured g suite correctly, congratulations you are now the proud owner of a domain!

Project Structure and Load Balancer

For the sake of simplicity and broader acceptance, the tutorial is further followed up upon using a widely used project structure, which looks something like this:

Example Project Structure

The important thing to note is to keep your landing page as index.html, this tells the load balancer to direct requests to this page when the the instance IP is hit externally. So, keep your project complete and ready to go, we will come back to it after we’ve set up the load balancer.

As the case with everything, there are multiple load balancers. In this tutorial we will be setting up Nginx. To install Nginx, ssh into your instance and run :

$ sudo apt update

$ sudo apt install nginx

Some important Nginx commands :

$ sudo systemctl stop nginx

$ sudo systemctl start nginx

$ sudo systemctl restart nginx

After your installation of Nginx is over, you can check the status by :

$ sudo systemctl status nginx

If you get a response back with [Active : active (running)] everything is working as expected.

Almost there, the only things needed to be done now are to put the project folder in the correct directory and editing the nginx config file.

On the instance move the project folder to :

/var/www/html, so that the path looks like /var/www/html/pred_project

A simple zip -> SFTP -> unzip should be enough for this step.

Lastly, lets edit the nginx configuration file at:

/etc/nginx/sites-enabled/default

replace root /var/www/html/ to root /var/www/html/pred_project;

That’s it! All done for now! We’re still a little while away from complete deployment to hit the instance IP from a browser and hit our purchased domain to view our landing page. That will all be covered in the next and final part of the tutorial. As always if you face any trouble, feel free to comment below!

--

--

Sagar Biswas
Sagar Biswas

Written by Sagar Biswas

All things data! Dabbling with tech at : http://sagsent.com/

No responses yet