How to deploy a web Application in different use cases

ยท

Say I have built a mean stack application for a college. And say the end users want to access the application anywhere in the campus. How and where do i deploy the code. What are the different options available for deployment. Can someone explain me in detail how the deployment works and how do I implement the above scenario.

and say after some time if the users requirements change and they would like to access the web application from any where across the globe. How and where do i deploy the code.

I have three servers running, i.e angular, node and mongo servers. How exactly do i deploy the whole application.

thank you in advance for your patience in reading and answering the question.

Comments (3)

Tapas Adhikary's photo

Hello there,

There are several ways to do it.

  • If you can afford having the Physical Machines or Virtual Machines(VM) to host these server and configure the IPs such that they are accessible to your target users, your problem would be solved. However this is not as easy as it may sound. You will have the need to manage and maintain these server boxes and the availability of these also a big concern at times. Moreover getting a Static IP to configure and give it to your end-users may not be possible always.

    However, in case you want to go along this path, you need to make sure, you are building the client side using the build command and the built artifacts are served by a web application server like tomcat, JBoss, Glasssfish etc. You need to select one of them and follow their documentations to set it up for you. You also need to make sure to do, the proxy setup such that, your API calls can be made from the client side without getting through CORS related issues.

    Hosting the node and mongo and running shouldn't be a major problem as long as there is no port conflicts. Remember, you can host all the three on the same VM/Physical Machine

  • If you do not have the VMs or Physical Machines, you can think of hosting them on the cloud platforms like, Google Cloud Platform(as PaaS) where you can host node apps and now Mongo also available as a SaaS service with GCP . But this option may be limited by the major factor, Price, even there are free schemes and all provided by each of these Cloud Providers

  • (My Preferred way): I wouldn't spend any hours in doing all that I have mentioned above. I would take advantage of few other Cloud Providers who facilitate the deployment with ease. Couple of them I liked and used:

    Alright, so why is this my preferred approach? Because, you can establish a CI/CD with these platforms and your Source Code Management System say, Git. As you push a code/ merge a branch, the deployment takes place automatically and the service gets up and running very quickly. That makes you as a developer very happy and your end-users super happy ๐Ÿ˜Š.

adhi narayan's photo

Thank you so much for a really simple and crisp answer. After reading through your entire answer, i got a few doubts.

" 1) However, in case you want to go along this path, you need to make sure, you are building the client side using the build command and the built artifacts are served by a web application server like tomcat, JBoss, Glassfish etc. You need to select one of them and follow their documentations to set it up for you.

2) You also need to make sure to do, the proxy setup such that, your API calls can be made from the client side without getting through CORS related issues "

for 1) why cant i simply do npm start in the server machine and let angular run? Why use web application server. And i have also heard of nginx. Is it similar to glassfish, JBoss? What is the function of such servers..

for 2) What is a proxy and CORS issues. I have searched online but i really could not understand.

I would be really grateful if you can answer these questions just like you answered the above one and provide links to enhance my knowledge more. Thank you for your patience.

Tapas Adhikary's photo

adhi narayan ,

1) why cant i simply do npm start in the server machine and let angular run? Why use web application server. And i have also heard of nginx. Is it similar to glassfish, JBoss? What is the function of such servers..

You always can. You can chose to do npm start and run the app in development mode where a dev server would host the app. If this is fine for you, go ahead. But with most of the real-life app, you would like to make it production ready like, the source files are minified, code is obfuscated etc..

If you would like to leverage these, you may have to build the app with a command setup by you in package.json file(example, npm run build or ng build etc). This will produce the built artifacts(all minified, chunked etc). Now these built artifacts need to be hosted by a web app server. In this case, you would need the options I had mentioned. If you are using something like angular-cli.. you can do ng-build and ng serve to serve from the built artifacts. There are always ways.. all differentiated by the fact, What do you need?

2) What is a proxy and CORS issues. I have searched online but i really could not understand.

CORS is CROSS ORIGIN RESOURCE SHARING. Read about it from here, https://en.wikipedia.org/wiki/Cross-origin_resource_sharing. It says, CORS is a mechanism that allows restricted resources on a web page to be requested from another domain outside the domain from which the first resource was served.

Here we are talking about domains.. which fairly a combination of the hostname/ip and port. So even two apps are hosted on same hostname/ip, if the port differed they will be restricted by CORS unless there are mechanisms established for not restricting it.

One useful way is by Proxy. I would encourage you to read this piece to understand the concept better.

It was great interacting with you, Thanks!