Decentralization / Social media

Building a Debate App: Part 14

Setting up a WebRTC server

Jeremy Orme
Published in
2 min readJul 6, 2023

--

Photo by Gabriel Heinzer on Unsplash

In the next part, we’ll be looking at adding a signature to a vote. In preparation for this, I have added a feature to Bonono that can be enabled for a particular collection to automatically add a signature to entries and validate it.

Adding this feature has taken some time because I discovered that the Bonono unit tests really needed some improvement. Therefore, I added code coverage reporting and refactored the tests to make them more readable.

In the meantime, the WebRTC signaling server that I set up last year stopped working and I lost access to it. I reinstalled the server, basically following the very useful instructions in this article:

Although the above article is very good, I thought it would be useful to document the exact instructions I followed for anyone else to reproduce (and for myself for the next time I lose access to my server!).

The nyk.webrtc-star.bonono.org signaling server is provided by me for development purposes so if you have built your own app and it’s ready for production, you’ll want to set up your own.

Prerequisites

  • Buy cheapest (512MB) VPS server plan ($22.99/yr at time of writing)
  • Buy a domain name, if you don’t have one
  • Set an A record to point to your VPS server IP

Steps to set up a signaling server

  • Install Ubuntu 20.04 (later versions require 1GB RAM)
  • Log in and type:
mkdir wrtc-star
cd wrtc-star
vi docker-compose.yml
  • Hit i to enter insert mode and paste the following text (replace nyk.webrtc-star.bonono.org with your own domain):
version: "3.3"
services:

js-libp2p-webrtc-star:
image: libp2p/js-libp2p-webrtc-star
environment:
- VIRTUAL_HOST=nyk.webrtc-star.bonono.org
- LETSENCRYPT_HOST=nyk.webrtc-star.bonono.org
- VIRTUAL_PORT=9090
networks:
service_network:

nginx-proxy:
image: jwilder/nginx-proxy
ports:
- 443:443
- 80:80
container_name: nginx-proxy
networks:
service_network:
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
- nginx-certs:/etc/nginx/certs
- nginx-vhost:/etc/nginx/vhost.d
- nginx-html:/usr/share/nginx/html
depends_on:
- js-libp2p-webrtc-star

nginx-proxy-letsencrypt:
image: jrcs/letsencrypt-nginx-proxy-companion
environment:
NGINX_PROXY_CONTAINER: "nginx-proxy"
networks:
service_network:
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- nginx-certs:/etc/nginx/certs
- nginx-vhost:/etc/nginx/vhost.d
- nginx-html:/usr/share/nginx/html

networks:
service_network:

volumes:
nginx-certs:
nginx-vhost:
nginx-html:
  • Press Esc to exit insert mode and :wq to save and quit
  • Type the following commands to get docker and set up the server:
apt update
apt -yy install docker.io docker-compose
docker-compose up -d

I hope this has been useful for anyone wanting to set up their own signaling server.

Next time, we’ll get back to developing our debate app by making use of the new Bonono feature I mentioned to ensure the authenticity of votes.

--

--

Jeremy Orme
Coinmonks

Software engineer. Experimenting with database decentralization