How to Deploy Node.js Shopify Apps to Digital Ocean

A comprehensive guide to deploying your Node.js Shopify App to a production-grade Digital Ocean server

Table of Contents

Why Digital Ocean

Prerequisites

Creating a Digital Ocean Droplet

Digital Ocean Dashboard — Selecting a Droplet
Digital Ocean Dashboard — Selecting a droplet
Digital Ocean Dashboard — Selecting a region

Configuring DNS

Configuring the Shopify Partner Dashboard App Setup

Configuring the Shopify Partner Dashboard App Setup

Setting up a non-root user and firewall

Installing NGINX

sudo apt update
sudo apt install nginx
sudo ufw allow 'Nginx Full'
NGINX welcome message
sudo nano /etc/nginx/sites-available/test.northern-apps.com
server {
listen 80;
listen [::]:80;
server_name test.northern-apps.com; location / {
proxy_pass http://localhost:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
sudo ln -s /etc/nginx/sites-available/test.northern-apps.com /etc/nginx/sites-enabled/
sudo systemctl restart nginx

Setup HTTPS

sudo add-apt-repository ppa:certbot/certbot
sudo apt install python-certbot-nginx
sudo certbot --nginx -d test.northern-apps.com

Install Node.js

cd ~
curl -sL https://deb.nodesource.com/setup_8.x -o nodesource_setup.sh
sudo bash nodesource_setup.sh
sudo apt install nodejs

Install NVM

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.1/install.sh | bash
nvm install v11.3.0

Clone your project using Git

cd ~
git clone https://github.com/chris-geelhoed/shopify-demo.git

Setup Environmental Variables

sudo nano shopify-demo/.env
SHOPIFY_API_KEY=<API KEY HERE>
SHOPIFY_API_SECRET=<API SECRET HERE>
SCOPES=write_products,write_customers,write_draft_orders
HOST=https://test.northern-apps.com

Build the Project

cd shopify-demo
npm install
npm run build

Test Your Project By Running Node.js Directly

PORT=8080 npm run start
Node.js Shopify App working!

Upgrade to PM2

npm install -g pm2
PORT=8080 pm2 start npm --name "shopify-demo" -- start
pm2 startup systemd
sudo env PATH=$PATH:/home/chris/.nvm/versions/node/v11.3.0/bin /home/chris/.nvm/versions/node/v11.3.0/lib/node_modules/pm2/bin/pm2 startup systemd -u chris --hp /home/chris

Running Multiple Apps

What’s Next

Software developer and teacher

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store