Kailash Choudhary
Kailash Choudhary

Reputation: 600

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.

Upvotes: 2

Views: 6374

Answers (2)

Darryl RN
Darryl RN

Reputation: 8228

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"

Upvotes: 6

Rukeith
Rukeith

Reputation: 673

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.

Upvotes: -1

Related Questions