Skip to content

Commit 46036eb

Browse files
feat: use Supabase networks (#39)
1 parent 2c1396d commit 46036eb

File tree

4 files changed

+23
-7
lines changed

4 files changed

+23
-7
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# PowerSync Self Hosted Example
22

3+
## v0.6.0
4+
5+
- Use Supabase Docker networks. This removes the use of `host.docker.internal` which is not always available on all Systems.
6+
37
## v0.5.2
48

59
- Added note for PowerSync service memory limits using the `NODE_OPTIONS` environment variable.

demos/supabase/.env.template

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@
33
SUPABASE_URL=http://localhost:54321
44
SUPABASE_ANON_KEY=
55

6-
# The Supabase Postgres connection is available on the host
7-
PG_DATABASE_HOSTNAME=host.docker.internal
6+
# The Supabase Postgres connection is available in the Supabase network
7+
# The Postgres container name is of the form `supabase_db_${project_id}`
8+
# Where `project_id` is configured in the config.toml file.
9+
PG_DATABASE_HOSTNAME=supabase_db_powersync_demo
810
PG_DATABASE_NAME=postgres
9-
PG_DATABASE_PORT=5433 #This port has been configured in supabase/config.toml
11+
# This is the port in the Supabase network
12+
# The Postgres DB is exposed on a different port for the host
13+
PG_DATABASE_PORT=5432
1014
PG_DATABASE_USER=postgres
1115
PG_DATABASE_PASSWORD=postgres
1216
PS_DATA_SOURCE_URI=postgres://${PG_DATABASE_USER}:${PG_DATABASE_PASSWORD}@${PG_DATABASE_HOSTNAME}:${PG_DATABASE_PORT}/${PG_DATABASE_NAME}

demos/supabase/docker-compose.yaml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ services:
1515
condition: service_completed_successfully
1616
volumes:
1717
- ./config:/config
18-
environment:
19-
PS_PG_URI: postgres://${PG_DATABASE_USER}:${PG_DATABASE_PASSWORD}@${PG_DATABASE_HOSTNAME}:${PG_DATABASE_PORT}/${PG_DATABASE_NAME}
18+
networks:
19+
- default
20+
- supabase_network_powersync_demo
2021

2122
demo-client:
2223
build:
@@ -27,3 +28,10 @@ services:
2728
VITE_POWERSYNC_URL: http://localhost:${PS_PORT}
2829
ports:
2930
- 4170:4173
31+
32+
# Supabase exposes their services on this network
33+
networks:
34+
# This is derived from `supabase_network_${project_id}`
35+
# Where project_id is defined in the `config.toml` file.
36+
supabase_network_powersync_demo:
37+
external: true

demos/supabase/supabase/config.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# A string used to distinguish different Supabase projects on the same host. Defaults to the
22
# working directory name when running `supabase init`.
3-
project_id = "project"
3+
project_id = "powersync_demo"
44

55
[api]
66
enabled = true
@@ -17,7 +17,7 @@ max_rows = 1000
1717

1818
[db]
1919
# Port to use for the local database URL.
20-
port = 5433
20+
port = 54322
2121
# Port used by db diff command to initialize the shadow database.
2222
shadow_port = 54320
2323
# The database major version to use. This has to be the same as your remote database's. Run `SHOW

0 commit comments

Comments
 (0)