Skip to content

Commit c239111

Browse files
authored
Merge pull request #117 from supabase-community/feat/deploy-with-supabase
feat: database deployment on Supabase
2 parents ee734fa + 3c8fab8 commit c239111

File tree

80 files changed

+12444
-959
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+12444
-959
lines changed

.dockerignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
**/node_modules
2+
**/.next
3+
**/.turbo
4+
**/.env*

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,4 @@ tls/
4141
dist/
4242

4343
.env
44+
.turbo

README.md

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,63 @@ How is this possible? [PGlite](https://pglite.dev/), a WASM version of Postgres
2323

2424
This is a monorepo split into the following projects:
2525

26-
- [Frontend (Next.js)](./apps/postgres-new/): This contains the primary web app built with Next.js
27-
- [Backend (pg-gateway)](./apps/db-service/): This serves S3-backed PGlite databases over the PG wire protocol using [pg-gateway](https://github.com/supabase-community/pg-gateway)
26+
- [Web](./apps/postgres-new/): The primary web app built with Next.js
27+
- [Browser proxy](./apps/browser-proxy/): Proxies Postgres TCP connections back to the browser using [pg-gateway](https://github.com/supabase-community/pg-gateway) and Web Sockets
28+
- [Deploy worker](./apps/deploy-worker/): Deploys in-browser databases to database platforms (currently Supabase is supported)
29+
30+
### Setup
31+
32+
From the monorepo root:
33+
34+
1. Install dependencies
35+
36+
```shell
37+
npm i
38+
```
39+
40+
2. Start local Supabase stack:
41+
```shell
42+
npx supabase start
43+
```
44+
3. Store local Supabase URL/anon key in `./apps/postgres-new/.env.local`:
45+
```shell
46+
npx supabase status -o env \
47+
--override-name api.url=NEXT_PUBLIC_SUPABASE_URL \
48+
--override-name auth.anon_key=NEXT_PUBLIC_SUPABASE_ANON_KEY |
49+
grep NEXT_PUBLIC >> ./apps/postgres-new/.env.local
50+
```
51+
4. Create an [OpenAI API key](https://platform.openai.com/api-keys) and save to `./apps/postgres-new/.env.local`:
52+
```shell
53+
echo 'OPENAI_API_KEY="<openai-api-key>"' >> ./apps/postgres-new/.env.local
54+
```
55+
5. Store local KV (Redis) vars. Use these exact values:
56+
57+
```shell
58+
echo 'KV_REST_API_URL="http://localhost:8080"' >> ./apps/postgres-new/.env.local
59+
echo 'KV_REST_API_TOKEN="local_token"' >> ./apps/postgres-new/.env.local
60+
```
61+
62+
6. Start local Redis containers (used for rate limiting). Serves an API on port 8080:
63+
64+
```shell
65+
docker compose -f ./apps/postgres-new/docker-compose.yml up -d
66+
```
67+
68+
7. Fill in the remaining variables for each app as seen in:
69+
70+
- `./apps/postgres-new/.env.example`
71+
- `./apps/browser-proxy/.env.example`
72+
- `./apps/deploy-worker/.env.example`
73+
74+
### Development
75+
76+
From the monorepo root:
77+
78+
```shell
79+
npm run dev
80+
```
81+
82+
_**Important:** This command uses `turbo` under the hood which understands the relationship between dependencies in the monorepo and automatically builds them accordingly (ie. `./packages/*`). If you by-pass `turbo`, you will have to manually build each `./packages/*` before each `./app/*` can use them._
2883

2984
## Why rename postgres.new?
3085

apps/browser-proxy/README.md

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,9 @@ It is using a WebSocket server and a TCP server to make the communication betwee
88

99
Copy the `.env.example` file to `.env` and set the correct environment variables.
1010

11-
Install dependencies:
11+
Run the dev server from the monorepo root. See [Development](../../README.md#development).
1212

13-
```sh
14-
npm install
15-
```
16-
17-
Start the proxy in development mode:
18-
19-
```sh
20-
npm run dev
21-
```
13+
The browser proxy will be listening on ports `5432` (Postgres TCP) and `443` (Web Sockets).
2214

2315
## Deployment
2416

@@ -30,4 +22,4 @@ Deploy the app:
3022

3123
```sh
3224
fly deploy --app database-build-browser-proxy
33-
```
25+
```

apps/db-service/.dockerignore

Lines changed: 0 additions & 5 deletions
This file was deleted.

apps/db-service/Dockerfile

Lines changed: 0 additions & 68 deletions
This file was deleted.

apps/db-service/README.md

Lines changed: 0 additions & 101 deletions
This file was deleted.

apps/db-service/docker-compose.yml

Lines changed: 0 additions & 63 deletions
This file was deleted.

apps/db-service/entrypoint.sh

Lines changed: 0 additions & 38 deletions
This file was deleted.

0 commit comments

Comments
 (0)