Skip to content

Instantly share code, notes, and snippets.

@TrystonPerry
Last active August 31, 2020 19:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TrystonPerry/ec91687b77adff8a8c72f611e3221e82 to your computer and use it in GitHub Desktop.
Save TrystonPerry/ec91687b77adff8a8c72f611e3221e82 to your computer and use it in GitHub Desktop.
Setup a self-hosted Doice instance.

Self-Deploy a Doice Instance

Prerequisites

  • Domain or Subdomain
  • A VPS or Other Server
  • Some critical thinking skills

1) Get a VPS

For Doice, you will need to host it on a linux VPS like Digital Ocean, AWS, Azure or Google Cloud. Pick whatever you'd like but we recommend Digital Ocean due to it's fair pricing on bandwidth.

We recommend using Ubuntu. This guide is written with that in mind. You can use another kernal if you'd like, just keep that in mind.

Sign up with our affiliate link to get $100 in credit for your first 60 days. https://m.do.co/c/31cd872c964b

2) Install Dependencies

Once you have your VPS, ssh into it using the IP address the hosting provider gave you. Then, begin installing the required dependencies.

Update and Install Git

sudo apt-get update
apt-get install git

Install Node.js 12

curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt-get install -y nodejs

Install Mediasoup Dependencies

apt-get install python
apt-get install clang
apt-get install build-essential

*Check Mediasoup docs for more info https://mediasoup.org/documentation/v3/mediasoup/installation/

3) Install Doice

Download Doice-Server

git clone https://github.com/DoiceIO/doice-server

Install Node Dependencies

cd doice-server
npm i

This will take about 10 minutes. Get some coffee or a snack :)

Download Doice Webapp

mkdir public
cd public
git clone https://github.com/DoiceIO/doice-webapp

Install and Build Webapp

cd doice-webapp
npm i
npm run build
mv dist/* ..
cd ..
rm -rf doice-webapp
cd ..

Config Server .env

Config .env file
cp .env.template .env
nano .env
NODE_ENV=prod

LOCAL_IP=<Your VPS Server IP>
REMOTE_IP=<Your VPS Server IP>

PORT=3000
IP=

YOUTUBE_API_KEY=<Your YouTube API Key (Optional)>

Then save the file.

4) Set Up PM2

npm i pm2 -g
pm2 startup ubuntu

Go to app.pm2.io and register for an account. There, follow the instructions to add a new instance.

5) Nginx + Certbot

Install Nginx

apt install nginx
nano /etc/nginx/sites-available/default

Find this section of the Nginx config and make sure it mirrors this.

server_name yourdomain.com;

location / {
    proxy_pass http://localhost:3000; #Whatever port Doice runs on
    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;
}

Save it, then verify that the Nginx config is valid and restart Nginx.

sudo nginx -t
sudo service nginx restart

Set Up Certbot for SSL

Before this step, you will need to point a domain name to your servers IP address. The simplest way is to add a DNS A record that points to your servers' IP address.

sudo add-apt-repository ppa:certbot/certbot
sudo apt-get install software-properties-common
sudo add-apt-repository universe
sudo apt-get update
sudo apt-get install python3-certbot-nginx
sudo certbot --nginx -d yourdomain.com

Go through the process of registering for an SSL certificate.

Certificate is only valid for 90 days, test the renewal process with

certbot renew --dry-run

Done

Your Doice server should be available to visit at https://yourdomain.com. You can manage it from https://app.pm2.io.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment