Skip to content

Commit

Permalink
update supabase config template and description
Browse files Browse the repository at this point in the history
  • Loading branch information
Vonng committed Nov 24, 2024
1 parent ac33bfe commit b3ee705
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 242 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,14 @@ pg-citus: # citus group

<details><summary>Example: PostgreSQL for Self-hosting Supabase</summary><br>

The [`conf/supa.yml`](https://github.com/Vonng/pigsty/blob/main/conf/supa.yml) provision a PostgreSQL cluster for self-hosting [supabase](https://pigsty.io/docs/conf/supa/) as below:
You can launch a self-hosting supabase with MinIO and PostgreSQL with just two commands:

```bash
./install.yml
./supabase.yml
```

The [`conf/supa.yml`](https://github.com/Vonng/pigsty/blob/main/conf/supa.yml) just describe everything you need:

```yaml
# pg-meta, the underlying postgres database for supabase
Expand Down
4 changes: 3 additions & 1 deletion app/supabase/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ IMG_DIR=/tmp/docker/supabase

up:
docker compose up -d
start: up

stop: down
down:
docker compose down

Expand Down Expand Up @@ -66,4 +68,4 @@ load:
cat $(IMG_DIR)/kong.tgz | gzip -d -c - | docker load


.PHONY: default up down view log info restart clean edit pull save load tz tarball
.PHONY: default up down start stop view log info restart clean edit pull save load tz tarball
9 changes: 7 additions & 2 deletions app/supabase/client.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,21 @@
</head>
<body>
<h1>Supabase: the Hello World Demo</h1>
<h3>Javascript Snippet Demo</h3>
<code>
<p>const supabaseUrl = 'http://supa.pigsty';</p>
<p>const supabaseKey = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJhbm9uIiwKICAgICJpc3MiOiAic3VwYWJhc2UtZGVtbyIsCiAgICAiaWF0IjogMTY0MTc2OTIwMCwKICAgICJleHAiOiAxNzk5NTM1NjAwCn0.dc_X5iR_VP_qT0zsiyj_I_OZ2T9FtRU2BBNWN8Bu4GE';</p>
<p>const supabaseKey = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJzZXJ2aWNlX3JvbGUiLAogICAgImlzcyI6ICJzdXBhYmFzZS1kZW1vIiwKICAgICJpYXQiOiAxNjQxNzY5MjAwLAogICAgImV4cCI6IDE3OTk1MzU2MDAKfQ.DaYlNEoUrrEn2Ig7tqibS-PHK5vgusbcbo7X36XVt4Q';</p>
<p>const client = supabase.createClient(supabaseUrl, supabaseKey);</p>
</code>
<h3>Create sample table in supabase console</h3>
<code><p>create table countries (id int8 primary key, name text); insert into countries (id, name) values (1, 'USA'); -- do this in supabase console</p><br></code>

<h3>Async Fetch Results</h3>
<div id="data"></div>
<script>
const supabaseUrl = 'http://supa.pigsty';
const supabaseKey = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJhbm9uIiwKICAgICJpc3MiOiAic3VwYWJhc2UtZGVtbyIsCiAgICAiaWF0IjogMTY0MTc2OTIwMCwKICAgICJleHAiOiAxNzk5NTM1NjAwCn0.dc_X5iR_VP_qT0zsiyj_I_OZ2T9FtRU2BBNWN8Bu4GE';
const supabaseKey = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJzZXJ2aWNlX3JvbGUiLAogICAgImlzcyI6ICJzdXBhYmFzZS1kZW1vIiwKICAgICJpYXQiOiAxNjQxNzY5MjAwLAogICAgImV4cCI6IDE3OTk1MzU2MDAKfQ.DaYlNEoUrrEn2Ig7tqibS-PHK5vgusbcbo7X36XVt4Q';

const sb = supabase.createClient(supabaseUrl, supabaseKey);
async function fetchData() {
try {
Expand Down
2 changes: 0 additions & 2 deletions conf/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ In addition to the main templates, Pigsty provides a set of demo templates for d
* [demo/debian.yml](demo/debian.yml) : config file with all default parameters for debian/ubuntu systems.
* [demo/remote.yml](demo/remote.yml) : example config for monitoring a remote pgsql cluster or RDS PG.
* [demo/redis.yml](demo/redis.yml) : example config for redis clusters
* [demo/supa4.yml](demo/supa4.yml) : example config for 4-node supabase cluster



----------
Expand Down
222 changes: 0 additions & 222 deletions conf/demo/supa4.yml

This file was deleted.

17 changes: 10 additions & 7 deletions conf/supa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# Copyright : 2018-2024 Ruohang Feng / Vonng ([email protected])
#==============================================================#

# supabase is available on el8/el9/u22/u24/d12 with pg14,15,16,17
# supabase is available on el8/el9/u22/u24/d12 with pg15,16,17
# To install supabase on fresh node, run:
#
# curl -fsSL https://repo.pigsty.io/get | bash
Expand Down Expand Up @@ -92,14 +92,17 @@ all:
pg_vip_interface: eth1


# launch supabase stateless part with docker compose
# launch supabase stateless part with docker compose:
# ./supabase.yml
supabase:
hosts:
10.10.10.10: { supa_seq: 1 }
10.10.10.10: { supa_seq: 1 } # instance id
vars:
docker_enabled: true
#docker_registry_mirrors: ['https://docker.xxxxx.io'] # use these to pull docker images via proxy and mirror registries
supa_cluster: supa # cluster name
docker_enabled: true # enable docker

# use these to pull docker images via proxy and mirror registries
#docker_registry_mirrors: ['https://docker.xxxxx.io']
#proxy_env: # add [OPTIONAL] proxy env to /etc/docker/daemon.json configuration file
# no_proxy: "localhost,127.0.0.1,10.0.0.0/8,192.168.0.0/16,*.pigsty,*.aliyun.com,mirrors.*,*.myqcloud.com,*.tsinghua.edu.cn"
# #all_proxy: http://user:pass@host:port
Expand All @@ -111,8 +114,8 @@ all:
# IMPORTANT: CHANGE JWT_SECRET AND REGENERATE CREDENTIAL ACCORDING!!!!!!!!!!!
# https://supabase.com/docs/guides/self-hosting/docker#securing-your-services
jwt_secret: your-super-secret-jwt-token-with-at-least-32-characters-long
anon_key: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.ewogICJyb2xlIjogImFub24iLAogICJpc3MiOiAic3VwYWJhc2UiLAogICJpYXQiOiAxNzMyMzc3NjAwLAogICJleHAiOiAxOTkwMTQ0MDAwCn0.u0zKPMNEIkDb7XYvttXtOh9jJK0V_TLdfGp_C3HJ8h0
service_role_key: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.ewogICJyb2xlIjogImFub24iLAogICJpc3MiOiAic3VwYWJhc2UiLAogICJpYXQiOiAxNzMyMzc3NjAwLAogICJleHAiOiAyMDAwMDAwMDAwCn0.-7G2xzxp4AtwQoxK9I0vSZsCEpGV3e06WJy-s490h5k
anon_key: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJhbm9uIiwKICAgICJpc3MiOiAic3VwYWJhc2UtZGVtbyIsCiAgICAiaWF0IjogMTY0MTc2OTIwMCwKICAgICJleHAiOiAxNzk5NTM1NjAwCn0.dc_X5iR_VP_qT0zsiyj_I_OZ2T9FtRU2BBNWN8Bu4GE
service_role_key: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJzZXJ2aWNlX3JvbGUiLAogICAgImlzcyI6ICJzdXBhYmFzZS1kZW1vIiwKICAgICJpYXQiOiAxNjQxNzY5MjAwLAogICAgImV4cCI6IDE3OTk1MzU2MDAKfQ.DaYlNEoUrrEn2Ig7tqibS-PHK5vgusbcbo7X36XVt4Q
dashboard_username: supabase
dashboard_password: pigsty

Expand Down
Loading

0 comments on commit b3ee705

Please sign in to comment.