Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Production deployment on AWS EC2 #1323

Closed
sergical opened this issue Mar 1, 2017 · 7 comments
Closed

Production deployment on AWS EC2 #1323

sergical opened this issue Mar 1, 2017 · 7 comments

Comments

@sergical
Copy link

sergical commented Mar 1, 2017

I was developing the app on the remote EC2 server. So I have something like ec2-user/nextjsapp/ and spinning up localhost:3000 was no problem, I'd listen on the remote IP at port 3000.

Now I would like to publish it at a subdomain, without using a port (setting up port 80 to listen) but I am having trouble running next start -p 80 after I do next build within that folder.

What is the process to get the bundled, production ready nextjs app running?

Thanks 😃

@jamo
Copy link
Contributor

jamo commented Mar 1, 2017

Similar to hosting pretty much any node program.

The basic setup for any node app would be along the lines of:
Set up nginx that listens for 80 (and 443) with correct server_name (subdomain) and proxy passes to next.js (or any node) application running on a custom port, like 3000.

And then to make sure the next.js (or any node) app remains up, throw in a systemd service that runs the next start or npm run start and set it to restart it in case the process dies. and when the ec2 server restarts.

You might even want to wrap the node process to docker but to keep this short and simplified :D

@sergical
Copy link
Author

sergical commented Mar 1, 2017

any related links/resources off the top of your head @jamo ? this is some great info though, thanks!

@sergical
Copy link
Author

sergical commented Mar 1, 2017

also do I keep the app at home/ec2-user/nextjsapp or move it somewhere else? I am not super at setting stuff like this up. Do I keep the bundle as is or does next build do something that I don't know about to minify everything and get rid of all dev dependencies.

@jamo
Copy link
Contributor

jamo commented Mar 1, 2017

I had hard time finding a great tutorial but combining these two (or just going with the digital ocean one) should guide you thru similar setup that I described in short:

And you probably want to keep the dev version and deployed/production version in different folders so that they could co-exist

@sergical
Copy link
Author

sergical commented Mar 1, 2017

so could I run next build ../production and build the production version to that folder?

@sergical
Copy link
Author

sergical commented Mar 1, 2017

Also, using Amazon Linux, and can't seem to find systemd, is https://www.npmjs.com/package/pm2 a good way to go?

@sergical
Copy link
Author

sergical commented Mar 1, 2017

was about to use forever and configure application load balancing to proxy requests to port 3000.

Thanks for the help!

@sergical sergical closed this as completed Mar 1, 2017
@lock lock bot locked as resolved and limited conversation to collaborators May 12, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants