DEV Community

Cover image for Deploy NodeJS Application within 5 minutes
Dhruv Rajkotia
Dhruv Rajkotia

Posted on

Deploy NodeJS Application within 5 minutes

Now a days a lots of people are working on a side projects or the PoC(proof of concept) to showcase their work with rest of the world. For showing your work to rest of the world it required a deployment cost and also the person should have a knowledge regarding the deploying their apps to some server. Looking a bit weird 😟, right? Here I have come up with the quick solution for you guys. How we can deploy our NodeJs application within 5 minutes using App Engine.

Google App Engine is a cloud computing platform as a service for developing and hosting web applications in Google-managed data centers. App Engine offers automatic scaling for web applicationsβ€”as the number of requests increases for an application, App Engine automatically allocates more resources for the web application to handle the additional demand.

Google App Engine primarily supports Go, PHP, Java, Python, Node.js, .NET, and Ruby applications, although it can also support other languages via "custom runtimes". Here we are going to use the Standard environment provide some free quota which can be enough for showing our work to the world.πŸ€™

Step 1

First step is to create your own NodeJS project that you wanted to deploy using App Engine

Here is link of the sample boiler plate code for the NodeJS application. Link

You can clone (hint: git clone ) this repo in your local and our step 1 is done πŸ‘.

Step 2

We need to create a GCP project to deploy our Node application.

  1. Go to https://console.cloud.google.com/cloud-resource-manager
  2. Click on the create new project
  3. Provide Project name and location
  4. Click on the Create button.

Note: Make sure you have enabled the Cloud Build API and Enabled the Billing for your GCP project

You probably see that new project will be created. Congratulations πŸ‘ you have passed the 2nd stage πŸ’ͺ. To be honest you nailed it.πŸ˜„.

Step 3

Download Cloud SDK installer & setup our GCP project in local

Follow the steps mention in the official document of the Google.
Link

Once you have downloaded the Cloud SDK then go to the location of your repository.

Image description

1: Run the command: gcloud init
You probably see the below screen. (You may have some less options which I have in the below screenshot)

Image description

2: Select Create a new configuration option.

Image description

3: Copy Project ID from GCP Console.

Image description

4: Provide that project ID in Command prompt.
Probably you'll see the below screen.

Image description

5: Login with your Google Account

After that, Select Login with the new account option. So You'll be redirect to the new browser window for login. Login using the same account in which you have created your GCP project.

Image description

6: Select the project ID

Select the option for your project id. You'll see the success message in the CMD.

Congratulations guys, You just completed almost 80% πŸ‘

Step 4

Create app.yaml file

Create new file at the root level of the project structure.

Image description

Add below code snippet in your app.yaml file

runtime: nodejs16
Enter fullscreen mode Exit fullscreen mode

for more info regarding the app.yaml file, please have a look here

Step 5

Run Deploy Application Command

Run Below command to deploy your application in APP Engine

gcloud app deploy
Select the region of your APP Engine deployment

You'll see the App Deployment is in progress, Once it's done you'll get the public URL of your application which you can use it anywhere you want.

You'll see the below screen once deployment is done.

Image description

Open the URL mentioned in the response(For me: https://dhruv-rajkotia.uc.r.appspot.com/)

Note: Here you can also use the gcloud app browse command which open URL in the new browser window.

That's it, You have come too far to learn the deployment with App Engine. Hope 🀞 you liked it.

Please Follow me on Twitter to get update regarding upcoming blogs. Glad to connect with you guys😊.

Top comments (0)