Report this

What is the reason for this report?

Best practice for Deployments

Posted on February 1, 2018

Hi Guys,

This is a general question: I have the following setup:

  • 2 Droplets (one for production and the other for development)
  • Nginx (for reverse proxy ~ I have to subdomains api-dev and api that redirects to the respectively droplet)
  • Node.js Application (running as a daemon with pm2)
  • MongoDB

Right now the application is working as expected (Node.js and MongoDB on the same droplets), when I need to deploy a new change to production, basically i do the following steps:

  • Move to the application directory
  • git pull the changes (from master)
  • pm2 restart api (restart daemon)

Right now is very simple the process, I want to learn better ways (practices) to do it. So, I have a few question:

I have read a little about docker (but still don’t get it): How can I benefit from docker? Should I have an image for Node.js and another for MongoDB? (or just one with Node.js app and MongoDB installation)? Right now, If I add another droplet I need to modify the nginx, is there a way to automated? How can integrate the load balancer with nginx? Is it better to have the MongoDB in a separate droplet? (why or why not?)

*Please share any best practice about Deployments



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

“Is it better to have the MongoDB in a separate droplet? (why or why not?)”

Technically it should be in another droplet, or another third party instance, for separation of concerns.

“How can I benefit from docker?”

You can only benefit from Docker if you’re moving containers around without having to install OS level dependencies all over again in other instances like A*S.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.