Which is the best approach to deploy MERN stack app on AMAZON EC2? - node.js

I am googling a lot to be sure the best approach to deploy MERN stack app on aws ec2 ... in some examples Nginx being used in server (expressjs) part and in some cases its being used for Recatjs part and the express js part is just hosted in node , React even can be hosted in s3 I guesss .. so what is the best approach however?

Without configuring the server yourself in EC2, you can simply use managed Node.js hosting provided by AWS Elastic Beanstalk.
If you want to directly configure EC2 instance and deploy, you can follow this tutorial to do the deployment https://jasonwatmore.com/post/2019/11/18/react-nodejs-on-aws-how-to-deploy-a-mern-stack-app-to-amazon-ec2

Related

Can we implement frontend and backend separately on AWS Elastic beanstalk?

I have frontend and backend both are using nodejs. Frontend is exposed and every request for api goes through the proxy module in the frontend, and both frontend and backend communicate on different modes.
Is there a way to deploy the above module, using code pipeline onto the Elastic Beanstalk platform ?
Why not deploy the front end on Amplify AWS?
AWS Amplify is a set of tools and services that can be used together or on their own, to help front-end web and mobile developers build scalable full stack applications, powered by AWS.
You just need to link your Repo and select your branch and everything will be deployed and generate also a random free domain or you can set your domain from the domain management section

Deploying PERN stack application with AWS

I developed a PERN (postgres, express, react, node) app that's running on my local machine and I want do deploy it using AWS. What is the "best" way to go about doing this if I want to be able to continuously deploy changes and handle the potential of scaling?
For Database you can use RDS https://aws.amazon.com/rds/
For Hosting you can use EC2 Instance of your own https://aws.amazon.com/ec2/
You should dockerize your app
And Optionally can set up a continuous deployment pipeline using aws-codepipeline and aws-codedeploy . You can also use github actions for this purpose.

How to deploy Node.js Express server + Vue.js app on AWS EC2

I'm setting up my website which would run on an AWS Ubuntu EC2. It is a Vue.js SPA relying on a Nodejs Express app with API calls and socket.io. So far both apps are working, the backend is on my AWS EC2 free tier, behind an Elastic Load Balancer, the frontend is on my machine since I working on it. Now I would like to deploy the frontend to my AWS EC2 also but I'm confused how to do it correctly. The tutorials I've found are using nginx but I'm not sure that I need nginx as I already have AWS ELB. Any advices would be great :)
as is says "If you are developing your frontend app separately from your backend - i.e. your backend exposes an API for your frontend to talk to, then your frontend is essentially a purely static app" here
I would choose s3 to host vue app because it's static and can be served using s3 and
I will choose EC2 for hosting my API (server code) and also i'd make an elastic IP to talk to my ec2 server so that on restart i don't have to handle the dynamic IP's
Steps to make your website live
First pull yout node express server on your ec2 instance
start your node express server use pm2 to serve it as an service
expose the served port from security groups of the ec2 instance
make an s3 bucket on aws and upload files to it
Tip: just click upload button after dropping your files to s3 do not go clicking next
after uploading select all the uploaded files and then mark as public
after uploading go to properties of that bucket and then choose static web hosting and type index.html the asked field
** TIP: do not use a load balancer for this application use only when you distribute your system across multiple ec2's**

How to host a nodejs app on ECS?

Iam looking to host a nodejs app on ECS. On local dev i use ngrok to expose port 3000 and it seems to work well. Now i would like to host it. Is dockerizing mandatory? What would be the steps to host it on amazon ecs if the app is dockerized?
I would also like to know if hosting on ecs is possible without dockerizing.
I would suggest you if you want to go this way to start an EB Instance.
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_nodejs.container.html
And you can deploy your application using CodeShip or use the traditional way in EB where you upload and deploy the code ( I suggest you use CodeShip ).
Another way to do it, and it might end it up being free is Heroku, it's an amazing and easy cloud service where you can deploy your application and build a continuous integration with GitHub, it takes care of everything to you.
This is the walkthrough for Node.Js apps:
https://devcenter.heroku.com/articles/getting-started-with-nodejs#introduction
Dockerizing is not mandatory at all, you can do it if you like, the roadmap to deploy the app won't change.

I have an angular app with a Node server - no DB yet. How to deploy on AWS?

I'm not sure where and how to start with AWS for deploying, very confused at the moment. It seems like I deploy my server on Elastic Beanstalk, but then where does my build and static files go? S3 I'm guessing? Should I just follow the tutorial for Beanstalk? Thanks!
You can use Elastic Beanstalk to host your entire application including Static files where it will resides in the web server.
The downside of it is the performance for large scale applications where you can leverage AWS S3 and CloudFront. So if you are a starter with AWS, then I would recommend to consider Elastic Beanstalk for entire application hosting for the moment.

Resources