# Redux Tutorial: Deploy to DigitalOcean

Step 1: Create your DigitalOcean instance

First, create a new droplet in DigitalOcean by choosing an image (we are using Ubuntu for this tutorial), size, datacenter and adding your SSH keys. Once you have done that open a terminal and run the following command to SSH into the instance:


Once inside the newly created droplet, you need to install Git, NodeJS and MongoDB. DigitalOcean provides great tutorials for doing the same:

Once you have installed Git, NodeJS and MongoDB, you need to create a new directory to store your app like so:

$ mkdir ~/www

Then change the working directory to the newly created www directory like so:

$ cd ~/www

Then install a NPM module called deploy that makes it easy to initialize a new repostiory to which you can push your source code (use sudo if necessary):

$ npm install -g deploy

Then, initialize the Git repo:

$ deploy init simple ~/www/redux-todolist

Now, install another NPM module called PM2 which takes care of managing our running Node server (use sudo if necessary):

$ npm install -g pm2

Create a processes.json file that we will be using to start/stop/restart our Node server with PM2:

$ nano ~/processes.json

Paste the following configuration into the ~/processes.json file:

  "apps" : [{
    "name"        : "app",
    "script"      : "~/www/redux-todolist/server.js",
    "env": {
        "NODE_ENV": "production",
        "PORT": 80,

Step 2: Prepare your app

Open another terminal and change your current working directory in your development machine to redux-todolist. Modify the local redux-todolist/graphql.json file to point to your remote droplet. The changed redux-todolist/graphql.json file should look something like this:

  "development": {
    "endpoint": "http://localhost:8080/graphql"
  "production": {
    "endpoint": "http://<IP-ADDRESS-OF-DROPLET>/graphql"

Once you have made the changes, ready your project for production by creating a production build, like so:

$ npm run build:prod -s

Then, initialize a Git repo within the redux-todolist directory:

$ git init
$ git add .
$ git commit -m 'first commit'

Add a git remote to your running droplet like so:

$ git remote add origin ssh://root@<IP-ADDRESS-OF-DROPLET>/root/www/redux-todolist

After adding the remote, push to the Droplet like so:

$ git push origin master

Once you have successfully pushed the code to the droplet return to your SSH shell (if you have quit the shell you can always ssh root@<IP-ADDRESS-OF-DROPLET> back into the shell) and change your working directory to ~/www/redux-todolist and run npm install like so:

$ cd ~/www/redux-todolist
$ npm install
$ npm run load-sample -s

Once installed, launch the server via PM2 like so:

$ pm2 start ~/processes.json

This should launch your Node server and it should be accessible from http://<IP-ADDRESS-OF-DROPLET>.