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.
- Go to https://console.cloud.google.com/cloud-resource-manager
- Click on the create new project
- Provide Project name and location
- 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.
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)
2: Select Create a new configuration option.
3: Copy Project ID from GCP Console.
4: Provide that project ID in Command prompt.
Probably you'll see the below screen.
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.
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.
Add below code snippet in your app.yaml file
runtime: nodejs16
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.
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)