Re-deployment of next.js apps
Hi. I am a new user of Linode. I plan to use it primarily to host websites made with next.js, including the required databases.
I plan to use a combination of an ubuntu distribution, nginex and pm2 to serve the next.js apps and I believe that I can setup the system easily for the initial deployment (I am doing it already on my current server), but I am not sure of how to do efficient (i.e. automated) re-deployments when my apps change in the future. Currently, I ssh to the server, stop pm2, rebuild the next.js app and restart it with pm2.
This is Ok during development, but it is not acceptable in production.
Ideally, I would like to have a staging server and the ability to quickly roll-back to the previous working version if there are problems.
I would appreciate suggestions.
Thank you very much in advance.
1 Reply
I would suggest you look into configuring a CI/CD pipeline. Continuous Integration and Continuous Delivery software will allow you to do everything you mentioned.
Linode has created the following content which explores the topic of CI/CD:
- https://www.linode.com/docs/guides/introduction-ci-cd/
- https://www.linode.com/content/ci-cd-explained-how-devops-use-pipelines-for-automation/
All of these tools require the use of Version Control software such as Git to manage deployments.
There are many CI/CD platforms and tools available, some of which I have listed below:
- https://github.com/features/actions
- https://about.gitlab.com/stages-devops-lifecycle/auto-devops/
- https://www.jenkins.io/
This blog post which outlines how to use Github Actions to deploy a Next.js app might be useful as well:
Lastly, PM2 has a deployment system built-in with the ability to update and revert deployments: