Hosting Node Js Application in Jelastic PaaS / Yeti Cloud
Jeleastic is a cloud platform service where we can host our projects using different technologies. This can be a alternative platform if you want to reduce your hosting cost. It includes inbuilt features that made hosting applications easier than ever.
Now without wasting your time, I will show you the step by step process for hosting our node js application in a jelastic cloud. For this you need to have access of the jelastic cloud platform.
Step 1: Create a Environment
- Goto Dashboard and click New Enviroment
- You will get the dialog to create new environment like this
- This Dialog looks huge and confusing at first but let’s crack this step by step
- Here you can select your prefered environment configuration like At the top we can see different technology like node js, .net, python, java, php and if you require custom images or if you want to use public images then you can goto custom section.
Step 2 : Choose Application Server
We are hosting a node js application so we choose a node js then we need to select Application Server we want to use.
- We can select a specific version of the server as we like, or we can also use a docker image.
- I will just choose one of the node js versions and continue.
Step 3 : Choose Vertical Scaling configurations
We can vertically scale our application as we like we can choose the minimum required cloudlets at left side where it says Reserved and maximum required cloudlets on the right side where it says Scaling Limit and the scaling part will be done by the system itself depending on the resources used.
Step 4 : Choose Horizontal Scaling configurations
It also provides an option for horizontally scaling our application if we choose to add this nginx load balancer will automatically be configured. You also can change the default load balancer as you like but I am okay with the default one.
You have option to choose how many node you want to use for horizontally scaling you application.
Step 5 : View Your Pricing details
We can see daily, hourly or monthly pricing and plan accordingly.
Step 6 : Name your Environment
You can click create environment after this you you don’t need databases or other facilities in you application
Step 7 : Choose Database — (If Required)
- I have chosen mysql version 8, you can choose any database like mongodb, mariadb or any other.
- In the database too you can choose horizontal and vertical scaling and other configurations
Step 8 : Choose VPC, Storage — (If Required)
- You can choose your custom vpc where the environment runs.
- You can also use a shared storage service if required.
Step 9 : Create Environment
- Now you can click on create and it will start creating your environment
- It will send you database configuration data in your email account
You can see your environment like this after creating environment:
Deploy node js app to the Environment
- You can see Deployment manager at the bottom of the page
- You have different option for deployment like Archive
- You can zip your application files and upload it in jelastic deployment manager
- Or Must common way of doing things is using version control platform like github, gitlab
- We can add a repository in deployment manager GIT/SVN
- Give a name,url,branch and you also have to give login username and token or ssh key if your repository is private
- And Click Add+Deploy or add only
Now From Environment Application Server
- On Deployment -> Choose Deploy From Git/SVN
- Choose your repo you have added if not you can add now also.
- You can click Check and auto deploy will automatically fetch from git if new changes have been pushed
- And Click Deploy
In the Node js application we need to install a package to run the app so we do that from the default terminal, you can also add an ssh key and use your own terminal but i am using a web terminal.
After Entering into the terminal we goto /home/jelastic/ROOT path where our project is located.
And We will enter these command:
cd ROOT/ # goto projeect location
ls # see all project files
npm install # install dependencies
npm run build # if frontend need to be built
npm start # you can start server and check everthing is alright or you can use pm2 or any other services to start server
If we need to start application from something like app.js file or server.js file then we can run
node app.js or node server.js
But wait there’s easy way of doing this and will automatically run when server restarts
- Goto your environment list and application server
- Goto Variables and the dialog will popup
You can see APP_FILE there you can change the name of the file you want to start on restart of the server.
- Add your database host, user, password in env files if required
- Restart your server and open your app you will see your application running
Thank you so much for following along with this article or blog. I hope this helps you in your project. If you want more devops, software development contents then give me a follow and this is my first article so feedback will be appreciated.