Supabase Realtime
Supabase Realtime
by Supabase

Version 0.7.5

OS Ubuntu 18.04

DATABASES

Description

Listens to changes in a PostgreSQL Database and broadcasts them over WebSocket.
It works like this:

  1. the Phoenix server listens to PostgreSQL's replication functionality (using Postgres' logical decoding).
  2. it converts the byte stream into JSON.
  3. it then broadcasts over WebSocket.

You can use this together with our Supabase Postgres 1-Click App! Find out more in our GitHub repository.

Software Included

Getting started after deploying Supabase Realtime

Before we start, this droplet enables UFW that allows port 22 for SSH, port 5432 for PostgreSQL, and port 4000 for serving Supabase Realtime subscriptions. If you want to use different ports for your PostgreSQL database or Realtime, you have to configure UFW to allow those ports. Otherwise, read on!
Once the droplet is up and running, you first need to point Realtime to listen to your PostgreSQL database. First, SSH to the droplet instance, and edit /etc/realtime/realtime.env:

$ nano /etc/realtime/realtime.env

You'll see some environment variables you will need to set. If you are using our Supabase Postgres droplet, you simply need to set DB_HOST to the Postgres droplet's public IP, DB_PASSWORD to the password you set with \password postgres, and SECRET_KEY_BASE to a randomly generated secret which you can get by running the command below:

$ openssl rand -base64 48

Now you need the Realtime service to use the newly set environment variables:

$ systemctl daemon-reload && systemctl restart realtime

You can now disconnect from SSH. Now you should be able to visit your Realtime endpoint at http://your_realtime_droplet_ip:4000 and receive the greeting page, which means you're ready to subscribe to changes to your database with Realtime!
If you want to see the Realtime subscription in action, you can try our example code on GitHub.

API Creation

In addition to creating a Droplet from the Supabase Realtime 1-Click App via the control panel, you can also use the DigitalOcean API.

As an example, to create a 4GB Supabase Realtime Droplet in the SFO2 region, you can use the following curl command. You’ll need to either save your API access token to an environment variable or substitute it into the command below.


  curl -X POST -H 'Content-Type: application/json' \
       -H 'Authorization: Bearer '$TOKEN'' -d \
      '{"name":"choose_a_name","region":"sfo2","size":"s-2vcpu-4gb","image":"supabase-supabaserealtime-18-04"}' \
      "https://api.digitalocean.com/v2/droplets"
      

More DigitalOcean Links

DigitalOcean Community

Developers supporting developers

Ask a Question

Ask anything related to system administration, programming, devops, open source, or the DigitalOcean platform.

List your 1-Click App in the DigitalOcean Marketplace

Partner with us to build traction for your open source project or software company