简体   繁体   中英

How to deploy Next js on aws ec2 (linux instance)

I have created a next js application.

Now I'm trying to deploy it on an AWS ec2 instance. I can easily deploy it on ec2 instance just like on my development server(local server) ( I moved all code base to ec2 and running npm install, npm run build and npm run start ).

But the problem is that what about after we deploy any update on my application (adding new features), suppose if I follow the same procedure as above, in that case, I would need to stop the node server, but I don't want to stop it.

So please give me an alternative for this so that it can be easy to deploy and give an update to my app.

In other way, you can also use Docker and Kubernetes.

By using Docker, you already prepare the Docker image (do npm install and build inside the image) before deployment, and then just push the image, turn off the old container and re-run the newest docker image (will take less than a minute to re-deploy your app).

By using Kubernetes and Docker, you can re-deploy your app and Kubernetes will redirect the request to another node that running your app. Therefore 0 downtime during deployment.

Another important keyword "0 downtime deployment"

You have to stop node server. If you need to let user didn't find out the server is down. You could check about blue/green deploy, Rolling Update or Canary.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM