In our earlier guide, we discussed installation of AppWrite on own server. If you are developing ESP32 Arduino, then probably Supabase will feel more like Firebase.
Apart from Firebase, AppWrite, and Supabase, there are other options such as AceBase, Amplication, Conduit and so on. Supabase is one the most established BaaS provider among the three. In a sense, Supabase is nearly an equivalent which is very close to Appwrite. Supabase supports PostgreSQL, the opposite of the NoSQL approach in Appwrite. Regarding the cloud-hosted version of Supabase, it has a Free plan which is enough to test the IoT projects with ESP32 Arduino.
Supabase has an existing library for ESP32 (Arduino IDE):
---
1 | https://github.com/jhagas/ESP32-Supabase |
Also, there are a few tutorials:
1 | https://www.jhagas.space/posts/monitoring-data-logging-sensor-iot-supabase |
So the total thing is easier for a less advanced developer or a student. All the others including AppWrite are similar. You need something like Svelte or Netlify to deploy them. You can extend the functions by adding a notification system such as Novu. If you use all of them as cloud-hosted, you have no headache with backend management.
What we have done here in this guide ESP32 Arduino IoT Relay Control, can be done more professionally with these systems.
Steps to Install Supabase
You need a sub-domain or domain to complete the installation. First update, upgrade your server:
1 | sudo apt update && sudo apt upgrade |
Install the required packages and apps:
1 | sudo apt install nano git ufw software-properties-common dirmngr apt-transport-https gnupg2 ca-certificates lsb-release debian-archive-keyring -y |
Install Docker and Docker compose plugin:
1 2 3 4 5 | sudo apt-get install docker.io sudo apt install docker-compose-plugin sudo systemctl start docker sudo systemctl enable docker docker -v |
Clone the Supabase repository from GitHub:
1 | git clone --depth 1 https://github.com/supabase/supabase |
Open the .env
file:
1 | nano .env |
These default settings require changing:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ## General SITE_URL=http://localhost:3000 ADDITIONAL_REDIRECT_URLS= JWT_EXPIRY=3600 DISABLE_SIGNUP=false API_EXTERNAL_URL=http://localhost:8000 ## Mailer Config ... ... ############ # Studio - Configuration for the Dashboard ############ STUDIO_DEFAULT_ORGANIZATION=Default Organization STUDIO_DEFAULT_PROJECT=Default Project STUDIO_PORT=3000 # replace if you intend to use Studio outside of localhost SUPABASE_PUBLIC_URL=http://localhost:8000 |
Also edit POSTGRES_PASSWORD
, JWT_SECRET
etc fields.
Here you’ll get some info about this file:
1 | https://supabase.com/docs/guides/functions/secrets#production-secrets |
Open the official Supabase website on the browser – https://supabase.com/docs/guides/self-hosting#api-keys
… and enter that JWT_SECRET
to generate ANON_KEY
. In the same way, generate the SERVICE_KEY
.
Open docker-compose.yml
and edit the API_EXTERNAL_URL
and GOTRUE_SITE_URL
to ${SITE_URL}
. Open volumes/api/kong.yml
and find:
1 2 3 4 | consumers: - username: anon keyauth_credentials: - key: |
The key value will be ANON_KEY
.
find:
1 2 3 | - username: service_role keyauth_credentials: - key: |
The key value will be SERVICE_KEY
.
Change the directory to the repository’s Docker subdirectory:
1 | cd supabase/docker |
Copy the included configuration file:
1 | cp .env.example .env |
Now, run Supabase within the supabase/docker subdirectory:
1 | sudo docker compose up -d |
Next, install NGINX, follow any of our guides on installation of NGINX and/or Certbot.
You need to edit the configuration file at /etc/nginx/sites-available/default
. The configuration should look like this one after your editing:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | map $http_upgrade $connection_upgrade { default upgrade; '' close; } upstream supabase { server localhost:3000; } upstream kong { server localhost:8000; } server { listen 80; server_name localhost x.y.z.a example.com; # REST location ~ ^/rest/v1/(.*)$ { proxy_set_header Host $host; proxy_pass http://kong; proxy_redirect off; } # AUTH location ~ ^/auth/v1/(.*)$ { proxy_set_header Host $host; proxy_pass http://kong; proxy_redirect off; } # REALTIME location ~ ^/realtime/v1/(.*)$ { proxy_redirect off; proxy_pass http://kong; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; proxy_set_header Host $host; } # STUDIO location / { proxy_set_header Host $host; proxy_pass http://supabase; proxy_redirect off; proxy_set_header Upgrade $http_upgrade; } } |
Run nginx -t
and restart NGINX. You need to edit /etc/nginx/nginx.conf
later for optimization (search or site for articles on NGINX optimization).
After completion, you will be able to log in to Supabase.
Supabase requires some Postgres extensions to be enabled for the API and Auth system to work. Read the official direction on this webpage under Extension
sub-header – https://supabase.com/docs/guides/self-hosting
.