What is the right way to deploy Node/Express/Mongo/React app with Docker? - node.js

I have built an app using Node/Express/Mongo on the backend and React/Redux on the frontend. Now I am trying to figure out how to properly deploy this app using Docker.
Can you give me some advice on how to do this correctly?
Should I have 3 containers, one for node, one for mongo, and one for serving frontend files?
What is the right way to serve React in production?
Are there some good examples/tutorials about doing this?

Related

Angular SSR - Universal,

Build myself a Angular website and for my own learning curve, wanted to implement Angular Universal. Followed the tutorial: https://angular.io/guide/universal. Want to achieve that all the html is "prerendered" for better crawling/indexing by search engines.
But it looks like it needs a service worker or nodejs hosting to get this working? Isn't it possible with a shared/apache hosting? Or are there better ways to do this?
Thanks in advance!
You cannot serve the application with static files only. You must have a server that will render the HTML in every request.
Some of the options you can do is:
Use a cloud service like AWS Elastic Beanstalk
Launch a linux machine and serve through it (maybe with pm2, nginx)

how to deploy an ionic-react app to mobile if I'm using node js server in the backend?

I discovered ionic this week and I'm really considering using it at work.
Basically, my goal is to build an app that will work on android and Ios, where the needed functionality is to connect to the cloud over web socket and pull data from the cloud and show it on my phone. Maybe later I'll eventually need to consider using login but not for now at least.
Normally, if I'm building a web app. I ll use nodejs to pull the data from the cloud and expose it to the frontend. I ll write all code together and I ll host my app in Heroku or something where the entry point is my nodejs server right? So that my server needs to start and it will take care of the rest.
This is a bit confusing in ionic since I need to start the app with ionic serve, but somehow I also need to start my nodejs server too right? So I assume I can't write the server-side code inside the ionic app or am I wrong?
There is not much about this on the internet but I did some research and I guess that I should deploy (host) my nodejs server in the cloud (maybe using Heroku) and then connect to the server from my mobile app over the socket. Is this the right/only way to do this? are there any security issues with this method?
I find ionic great but I'm not sure if I should use it at work. Sincerely, this use case of using a backend server with ionic made me confused.
Ionic looks ideal for building cross-platform apps that does not need server-side scripting, but how complex can it be if I want to integrate some server-side code in my app? especially as I said I'm going to use some login forms in the future to extend the functionality of my app.
PS: I'm using ionic 6.10.1 and specifically I'm interested in using ionic with react not with angular.
After some search, I discovered that it isn't possible to deploy the frontend and backend code together. Therefore the trick is to deploy the nodejs server separate from the frontend.
Precisely, if it is a web app, then you should deploy the nodejs server in a separate host from the frontend. Then by starting the frontend app, you can communicate with the running nodejs server via socket or REST API.
Hope this helps someone in the future :)

How to deploy ReactJS frontend and NodeJS/Express backend from the same project folder?

GitHub repo: https://github.com/byeung2019/MIQSTechnologies
Hey guys,
This is my first time deploying a website online, so I'm confused and anxious of where to even begin.
My frontend is built using ReactJS, and my backend uses NodeJS/Express/GraphQL to fetch data from an external API (CryptoCompare).
My website works locally.
My frontend and backend each has its own unique package.json and .env file with its respective dependencies and dev dependencies.
Through my research it's been recommended to host the frontend using Netlify, and the backend with Heroku.
However, since this is my first time deploying, I'm confused about the following:
How to deploy the frontend and backend separately from the same project folder, with them having their own respective package.json file.
Would I need to rewrite code in index.js within the backend folder in order to connect my frontend GraphQL requests to my backend.
Thank you so much!
First of all this is a complicated question to provide an exact answer, you will have to google and learn few things. But here is a high level idea.
After developing any app using react or angularjs you can follow the build instructions and build the app. It is ng build --prod in angular for example. Then you just need the build to deploy and it does not depend on package.json
You have to deploy your backend app as it is and there is few options then you can follow most common is,
Using a proxy like nginx
Host your build inside the node backend
Here is a guide how to host your apps using nginx for nodejs and angular
https://www.journaldev.com/27234/nginx-reverse-proxy-node-angular
Hope you will get the idea.

Deploy Nodejs + ReactJs to Heroku

I'm learning how to deploy a web site to heroku.
My web app has a nodejs project and one mysql in the server side, a reactjs in the client side.
Can you show me the steps that I need to do? Because I'm new to this.
Thank you very much
Here is a step by step guide.
Put your app aside for a few moments and follow these:
To learn how to deploy a nodejs
https://devcenter.heroku.com/articles/deploying-nodejs
Now learning how to add a mysql database
https://devcenter.heroku.com/articles/cleardb#provisioning-the-shared-mysql-add-on
This will teach you how to deploy a 'raw' react app
https://blog.heroku.com/deploying-react-with-zero-configuration
Now, it's all about how you want things to be. You can have a route on your nodejs app that serves the index.html with the react app or a separate app for nodejs and for react. You should probably make them separated, just to keep things organized, but since it's your first deploy and you're probably using it as a hobby or to learn, any way is correct as long as you get it to work. Then you can build on top of that, split the apps into two, or maybe host the react app on aws s3. Who knows?

Architectural design of a Heroku application with Ember.js, Node.js and Express

I'm starting to implement a Heroku application based on Ember (frontend), Node and Express (backend).
I'm thinking to segregate the frontend and the backend in different apps. Both apps will be secured by Auth0.
What do you think about it? I'm on the right way?
Yes, I think you're going about it the right way. My company has a Ruby on Rails backend and EmberJS frontend. We have the backend as one heroku app, and the frontend as another heroku app. For ember, we use Ember CLI Deploy to deploy to production on Heroku.
Yes, that’s generally the preferred way to build Ember apps. We built the api viewer in this manner to have a reference app that works on Heroku with Fastboot that people could look at: https://github.com/ember-learn/ember-api-docs

Resources