3 ms·
What are the best practices for deploying a node.js app from git on Ubuntu behind nginx? I'm sure someone has a blog post on that but "Ghost" makes it a bit dif
by spindritf 13y ago
What are the best practices for deploying a node.js app from git on Ubuntu behind nginx? I'm sure someone has a blog post on that but "Ghost" makes it a bit difficult to google for.
In case anyone's looking, this PPA[1] seems to come recommended and has an up-to-date node.
[1] https://launchpad.net/~chris-lea/+archive/node.js/ https://launchpad.net/~chris-lea/+archive/node.js/
- hippich 13y agoI am using Dokku
- andreypopp 13y agoWhich in this case would make things a little more difficult cause Ghost uses SQLite and Dokku can't deploy apps which use it because of default Node.js Heroku buildpack which prohibits SQLite usage. You can patch a buildpack though. For example in my fork of Dokku I replaced Heroku buildpacks with plain Dockerfiles to define both a stack and a runtime dependencies — https://github.com/andreypopp/upaas https://github.com/andreypopp/upaas
- StavrosK 13y agoHow are you liking it? It's very handy for launching apps, for sure, but I'm wondering how you can configure services (e.g. how do I set up redis persistence or nginx directives or postgres backups?).
- NathanKP 13y agoThis is a good guide which explains the best technique I've found, and which I'm currently using in production for the startup I work for: http://blog.argteam.com/coding/hardening-node-js-for-production-part-3-zero-downtime-deployments-with-nginx/ http://blog.argteam.com/coding/hardening-node-js-for-product... Basically Nginx is used as a reverse proxy to serve requests from a pool of Node.js processes, each with its own internal port. So you would set up the Node.js app to run internally on ports 8080, 8081, 8082, and 8083 for example. (If you have a quad core server this assures that under extreme load each processor can be fully utilized by one single-thread Node.js process). Then Nginx serves requests on port 80 by fetching the response from one of those four internal ports in round robbin fashion. If one of the processes crashes due to a bug or you want to specifically restart it so that a new code update takes effect in production then Nginx will automatically remove it from the pool while it is down and then add it back when it comes back online. When you are pushing out code updates you can cycle each process one at a time to do a zero downtime deploy. The other cool thing that you can do with Nginx reverse proxies is use the proxy_cache as a robust cache layer to almost completely remove stress from your blog under high load. Honestly for a basic personal blog this technique probably isn't really necessary. You could just run it through Forever on port 80 with no Nginx and forget it, but if you expect tons of traffic, or if you want high 99% uptime, or if you just want to have some fun configuring a server then the technique I explained above is how you do it. It takes some fiddling to get Nginx configured properly and that tutorial I linked actually leaves out some details of the upstream server configuration but its pretty easy to figure out from the Nginx documentation.
- jackweirdy 13y agoIf you're looking to deploy to a larger platform (AWS scale deployments) check out the JuJu charm for node apps - https://juju.ubuntu.com/docs/howto-node.html https://juju.ubuntu.com/docs/howto-node.html
- Ethan_Mick 13y agoI used this[1], and it worked great. Setup my blog in 30 minutes or so. [1] http://0v.org/installing-ghost-on-ubuntu-nginx-and-mysql/ http://0v.org/installing-ghost-on-ubuntu-nginx-and-mysql/
- nickstinemates 13y agoI personally use Docker