When we structure our modern apps we typically have 2 microservices, one is the
api which is responsible of communicating with the database and provide you with custom logic, the other is the client which is typically a
web application that communicates with the
api. These are independently deployable.
There are many ways to deploy nowadays, but our focus here is to offer the simplest possible way of deploying in a solid, highly scalable fashion. The solutions we are providing are 100% free and require you no money to deploy and play with your apps, but at the same time you have the infrastructure to scale a lot.
- Go to https://www.heroku.com and create an account.
- Install the
npm i -g heroku. And then run
- You might need some other dependencies so all works flawlessly:
npm i -g @heroku/buildpack-registry true-myth valid-url
You need a solid database for MongoDB. Databases are usually a pain to maintain and scale, try to avoid managing your own unless you have to.
- Go to https://www.mongodb.com/cloud/atlas/register and create an account.
- Create a
free-tier cluster, create an admin username and ensure your security is set to "Allow all IP Addresses"
- Please select a very secure password. At least 12 chars.
We use need
heroku-buildpack-monorepo which allows an environment variable
APP_BASE to control this.
Note: the order of the buildpacks matter,
heroku-buildpack-monorepo needs to be first.
Netlify is also a good option, but for the sake of having everything done in a consistent manner, this is how it would work with Heroku.
To view the logs if something fails or the server's output:
Nowadays it's free and easy to deploy your app in safe, scalable manner. We love simplicity. The full working sample can be found here: https://github.com/kaviarjs/x-boilerplate