Backend Deployment
In this section we will deploy our backend code to a hosting provider. Our backend is developed using NodeJS, so we need a NodeJS compatible hosting provider. There are 2 ways to deploy a NodeJS project, one is using the NodeJS build file, and another one is using the CI/CD pipeline.
info
There are 2 types of hosting providers.
- Managed NodeJS hosting, also known as App Service or Functions. Example Heroku, Hostman, Render, Azure App Service, DigitalOcean App Platform, AWS Elastic Beanstalk, Google Cloud App Engine etc. This services can directly take code from your GitHub and deploy them.
- Self managed hosting, where you have to manage and maintain the cloud server and deployments. It's mostly suitable for large applications.
Managed NodeJS Hosting Using GitHub
- Create a
private
repository in Github: Follow https://docs.github.com/en/repositories/creating-and-managing-repositories/quickstart-for-repositories - Upload your backend code to your GitHub
private
repository. Follow official github guideline: https://docs.github.com/en/repositories/working-with-files/managing-files/adding-a-file-to-a-repository#adding-a-file-to-a-repository-using-the-command-line - After successfully uploading you backend code to GitHub, follow your Managed Hosting provider's guideline to deploy your backend code. This step is easy and straightforward.
- Remember to add
Environment variables
, without environment variables, server will fail to connect with database and other services. In some providers you might need to pressRedeploy
button after providing Environment variables.
Self-Managed Hosting
Follow your cloud service providers guideline to upload and deploy code.