How can I deploy a client-side ReactJS + Node.js application on Ubuntu Linux? - node.js

I have a client-side ReactJS and Node.js Express application running on the local machine at the moment. I would like to now deploy the client-side application to an Ubuntu Linux server, where the back-end, database and REST API, is already running.
What's the way to go about doing so? I did the research but all seem to have both front-end and back-end, and do not fit the criteria that I am looking for. So I was lost and reached out here. Thank you

Related

Deploying Express JS Server With Functions That Use Selenium WebDriver

I am a building an Express JS Server where some (at least 1) route uses Selenium to perform specific actions on another website in a browser. For example, I have a route: mywebsite.com/api/login that route should open a Selenium instance on Google Chrome that logs in to a specific website (e.g. anotherwebsite.com).
What is the best way to achieve this and which method or service can provide such service for Free for development and/or cheap. As well as being cheap for production.
Thank you!
You can develop own your own machine for free. Either Express.js or Selenium is FOSS. To host for production you can find any Linux VPS provider that runs Node.js. DigitalOcean, Vultr or Linode would be the more affordable option.

Deploy Node.js on tomcat

I have developed an application using Angular, Node/Express and MySQL. I have deployed my Angular application on the tomcat server, which is connected to some 10 PCs. However, I want to deploy my backend i.e, Node.js/Express.js on the same server as well since my app is totally dependent on the backend. How can I do that? I read online that one cannot deploy node.js on tomcat as both are separate servers. Do I have to install Node.js/MySQL separately on the same server? Isn't there any security threat linked to hosting the front-end and the back-end on the same server machine?
I would really appreciate if someone could clear my mind regarding this.
It's true that Tomcat and nodejs are separate web server programs, and you cannot run one within the other. You can run them both on the same machine, but they must use different ports.
You can use a reverse proxy server (nginx) to project the illusion to your end users that your Tomcat and nodejs apps run on the same server and port. Explaining how to do that is far beyond the scope of a SO answer.
You can share a database server (MySql) between the Java applications running on Tomcat and the Javascript.
There is no inherent security risk in hosting your front-end and back-end code on the same origin server. In fact, there are security advantages, because you can set up restrictive CORS rules.

Should I use a separate Socket.IO server or not?

I'm currently working on a Node.JS application which needs to be highly scalable for use in a particularly popular website.
Currently, the Node.JS and Socket.IO server is running as one application meaning to deploy a new release I just restart the server.
I've had suggestions to make the Socket.IO server separate to the Node.JS app running the site but feel as though this could make keeping the Javascript from the web server and Socket.IO server in sync tricky.
What should I do?

how to deploy and run multi language multi process app on heroku

I want to build an app with potentially large number of io and computation heavy logic.
I learnt that one way to tackle this is to use node.js as a client facing service, then pass on client request to another backend service for heavy computing, then return the result asychronously.
This means I'll have at least two processes in my app: a node.js server and a backend service written in another language.
I also want to use heroku, but how do I deploy such an architecture to heroku? Do I have to confine all web and worker processes in the same box? For example, if I have 10 dynos, I want 2 of them run the node web server, the other 8 run my backend service as worker, how do I deploy such an architecture?
First, if you really need multiple languages, you can use heroku-buildpack-multi.
Actually, both your Web dyno and your worker dynos could be node.js, if that works for you. In that case, you could use the exact setup described here.
At any rate, you can separately configure as many Web and Worker dynos as you want with heroku ps:scale as described in Heroku scaling. See also What is a Heroku Dyno?
You should check out MEAN stack.
http://mean.io/#!/
Mongo (or any Database really, for heroku I recommend Postgres if you don't want a NoSQL database).
Express This is you backend that handles communications from you front-end to you database
Angular Super powerful front-end Single Page Application with a HUGE community and tons of add-ons and goodies.
Node The server that makes this all possible.
It's all written in javascript.
Heroku itself is a platform similar to an AWS Server that has node on it that allows you to run Express. You will build your apps then use the heroku command line to deploy your app to their servers after you have created your account. Heroku will also host your database via heroku add-ons.
https://devcenter.heroku.com/articles/getting-started-with-nodejs
Dynos will dynamically handle you processes as needed. Node isn't really run so much as a service as its running your backend (Express). Think of Node like Apache, it's what is running your server. Express is the backend running on that server and can run async so you can have as many processes running as you want, that's where the dynos will start to load balance for you.

Where can I host a node.js chat bot?

I know this isnt coding but i dont know where else to look.
So I've written a chat bot using node.js and the socket.io-client module. Basically it's just a program that auto responds to messages on a chat room also written with node.js. The problem I have is hosting it. I have hosted it on my raspberry pi which works perfectly but isn't ideal as I sometimes want my pi for other things and this bot runs 24/7.
So, I looked around for some free node.js hosting. I found c9.io, heroku and appfog but all of them expect you to host websites with node.js and so aren't setup for my needs. I need a single instance to be always running but these hosts constantly restart and terminate the program causing all sorts of problems for me which wouldn't really be an issue if it was just outputting a web page.
So, is there anywhere that is suitable for hosting a node.js app like mine?
Have Amazon host it for you. That's what I'm doing with one of my projects. Just create an instance, I used Ubuntu for my OS, then installed Node.js and was good to go.
My recommendation will be to host it on openshift
https://www.openshift.com/app/account/new
Heroku is also widely used but in their free tier your bot has to "sleep" 6 hours
https://www.heroku.com/

Resources