Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

tweak(rnd): Move to the PG within Supabase (#8085)

Aarushi88e278b73603
diff --git a/autogpt_platform/backend/.env.example b/autogpt_platform/backend/.env.example
index ab536498a7..de15de840a 100644
--- a/autogpt_platform/backend/.env.example
+++ b/autogpt_platform/backend/.env.example
@@ -1,8 +1,8 @@
-DB_USER=agpt_user
-DB_PASS=pass123
-DB_NAME=agpt_local
-DB_PORT=5433
-DATABASE_URL="postgresql://${DB_USER}:${DB_PASS}@localhost:${DB_PORT}/${DB_NAME}"
+DB_USER=postgres
+DB_PASS=your-super-secret-and-long-postgres-password
+DB_NAME=postgres
+DB_PORT=5432
+DATABASE_URL="postgresql://${DB_USER}:${DB_PASS}@localhost:${DB_PORT}/${DB_NAME}?connect_timeout=60&schema=platform"
PRISMA_SCHEMA="postgres/schema.prisma"
REDIS_HOST=localhost
@@ -15,7 +15,7 @@ APP_ENV="local"
PYRO_HOST=localhost
SENTRY_DSN=
# This is needed when ENABLE_AUTH is true
-SUPABASE_JWT_SECRET=
+SUPABASE_JWT_SECRET=our-super-secret-jwt-token-with-at-least-32-characters-long
## ===== OPTIONAL API KEYS ===== ##
diff --git a/autogpt_platform/backend/README.md b/autogpt_platform/backend/README.md
index 19ec7be290..fc0c6b3944 100644
--- a/autogpt_platform/backend/README.md
+++ b/autogpt_platform/backend/README.md
@@ -58,7 +58,7 @@ We use the Poetry to manage the dependencies. To set up the project, follow thes
6. Migrate the database. Be careful because this deletes current data in the database.
```sh
- docker compose up postgres redis -d
+ docker compose up db redis -d
poetry run prisma migrate dev
```
diff --git a/autogpt_platform/docker-compose.platform.yml b/autogpt_platform/docker-compose.platform.yml
index a0f76cd343..a154d364a0 100644
--- a/autogpt_platform/docker-compose.platform.yml
+++ b/autogpt_platform/docker-compose.platform.yml
@@ -1,20 +1,4 @@
services:
- postgres:
- image: ankane/pgvector:latest
- environment:
- - POSTGRES_USER=agpt_user
- - POSTGRES_PASSWORD=pass123
- - POSTGRES_DB=agpt_local
- healthcheck:
- test: pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB
- interval: 10s
- timeout: 5s
- retries: 5
- ports:
- - "5433:5432"
- networks:
- - app-network
-
migrate:
build:
context: ../
@@ -27,10 +11,10 @@ services:
target: autogpt_platform/backend/migrate
action: rebuild
depends_on:
- postgres:
+ db:
condition: service_healthy
environment:
- - DATABASE_URL=postgresql://agpt_user:pass123@postgres:5432/agpt_local?connect_timeout=60
+ - DATABASE_URL=postgresql://postgres:your-super-secret-and-long-postgres-password@db:5432/postgres?connect_timeout=60&schema=platform
networks:
- app-network
restart: on-failure
@@ -67,7 +51,7 @@ services:
depends_on:
redis:
condition: service_healthy
- postgres:
+ db:
condition: service_healthy
migrate:
condition: service_completed_successfully
@@ -75,7 +59,7 @@ services:
- SUPABASE_URL=http://kong:8000
- SUPABASE_JWT_SECRET=your-super-secret-jwt-token-with-at-least-32-characters-long
- SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJhbm9uIiwKICAgICJpc3MiOiAic3VwYWJhc2UtZGVtbyIsCiAgICAiaWF0IjogMTY0MTc2OTIwMCwKICAgICJleHAiOiAxNzk5NTM1NjAwCn0.dc_X5iR_VP_qT0zsiyj_I_OZ2T9FtRU2BBNWN8Bu4GE
- - DATABASE_URL=postgresql://agpt_user:pass123@postgres:5432/agpt_local?connect_timeout=60
+ - DATABASE_URL=postgresql://postgres:your-super-secret-and-long-postgres-password@db:5432/postgres?connect_timeout=60&schema=platform
- REDIS_HOST=redis
- REDIS_PORT=6379
- REDIS_PASSWORD=password
@@ -102,7 +86,7 @@ services:
depends_on:
redis:
condition: service_healthy
- postgres:
+ db:
condition: service_healthy
migrate:
condition: service_completed_successfully
@@ -110,7 +94,7 @@ services:
- NEXT_PUBLIC_SUPABASE_URL=http://kong:8000
- SUPABASE_JWT_SECRET=your-super-secret-jwt-token-with-at-least-32-characters-long
- SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJhbm9uIiwKICAgICJpc3MiOiAic3VwYWJhc2UtZGVtbyIsCiAgICAiaWF0IjogMTY0MTc2OTIwMCwKICAgICJleHAiOiAxNzk5NTM1NjAwCn0.dc_X5iR_VP_qT0zsiyj_I_OZ2T9FtRU2BBNWN8Bu4GE
- - DATABASE_URL=postgresql://agpt_user:pass123@postgres:5432/agpt_local?connect_timeout=60
+ - DATABASE_URL=postgresql://postgres:your-super-secret-and-long-postgres-password@db:5432/postgres?connect_timeout=60&schema=platform
- REDIS_HOST=redis
- REDIS_PORT=6379
- REDIS_PASSWORD=password
@@ -134,7 +118,7 @@ services:
target: autogpt_platform/backend/
action: rebuild
depends_on:
- postgres:
+ db:
condition: service_healthy
redis:
condition: service_healthy
@@ -144,7 +128,7 @@ services:
- SUPABASE_URL=http://kong:8000
- SUPABASE_JWT_SECRET=your-super-secret-jwt-token-with-at-least-32-characters-long
- SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJhbm9uIiwKICAgICJpc3MiOiAic3VwYWJhc2UtZGVtbyIsCiAgICAiaWF0IjogMTY0MTc2OTIwMCwKICAgICJleHAiOiAxNzk5NTM1NjAwCn0.dc_X5iR_VP_qT0zsiyj_I_OZ2T9FtRU2BBNWN8Bu4GE
- - DATABASE_URL=postgresql://agpt_user:pass123@postgres:5432/agpt_local?connect_timeout=60
+ - DATABASE_URL=postgresql://postgres:your-super-secret-and-long-postgres-password@db:5432/postgres?connect_timeout=60&schema=platform
- REDIS_HOST=redis
- REDIS_PORT=6379
- REDIS_PASSWORD=password
@@ -165,27 +149,47 @@ services:
target: autogpt_platform/market/
action: rebuild
depends_on:
- postgres:
+ db:
condition: service_healthy
- migrate:
+ market-migrations:
condition: service_completed_successfully
environment:
- SUPABASE_URL=http://kong:8000
- SUPABASE_JWT_SECRET=your-super-secret-jwt-token-with-at-least-32-characters-long
- SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJhbm9uIiwKICAgICJpc3MiOiAic3VwYWJhc2UtZGVtbyIsCiAgICAiaWF0IjogMTY0MTc2OTIwMCwKICAgICJleHAiOiAxNzk5NTM1NjAwCn0.dc_X5iR_VP_qT0zsiyj_I_OZ2T9FtRU2BBNWN8Bu4GE
- - DATABASE_URL=postgresql://agpt_user:pass123@postgres:5432/agpt_local?connect_timeout=60&schema=market
+ - DATABASE_URL=postgresql://postgres:your-super-secret-and-long-postgres-password@db:5432/postgres?connect_timeout=60&schema=market
ports:
- "8015:8015"
networks:
- app-network
+ market-migrations:
+ build:
+ context: ../
+ dockerfile: autogpt_platform/market/Dockerfile
+ command: ["sh", "-c", "poetry run prisma migrate deploy"]
+ develop:
+ watch:
+ - path: ./
+ target: autogpt_platform/market/
+ action: rebuild
+ depends_on:
+ db:
+ condition: service_healthy
+ environment:
+ - SUPABASE_URL=http://kong:8000
+ - SUPABASE_JWT_SECRET=your-super-secret-jwt-token-with-at-least-32-characters-long
+ - SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJhbm9uIiwKICAgICJpc3MiOiAic3VwYWJhc2UtZGVtbyIsCiAgICAiaWF0IjogMTY0MTc2OTIwMCwKICAgICJleHAiOiAxNzk5NTM1NjAwCn0.dc_X5iR_VP_qT0zsiyj_I_OZ2T9FtRU2BBNWN8Bu4GE
+ - DATABASE_URL=postgresql://postgres:your-super-secret-and-long-postgres-password@db:5432/postgres?connect_timeout=60&schema=market
+ networks:
+ - app-network
# frontend:
# build:
# context: ../
# dockerfile: autogpt_platform/frontend/Dockerfile
# target: dev
# depends_on:
-# postgres:
+# db:
# condition: service_healthy
# rest_server:
# condition: service_started
@@ -196,7 +200,7 @@ services:
# environment:
# - NEXT_PUBLIC_SUPABASE_URL=http://kong:8000
# - NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJhbm9uIiwKICAgICJpc3MiOiAic3VwYWJhc2UtZGVtbyIsCiAgICAiaWF0IjogMTY0MTc2OTIwMCwKICAgICJleHAiOiAxNzk5NTM1NjAwCn0.dc_X5iR_VP_qT0zsiyj_I_OZ2T9FtRU2BBNWN8Bu4GE
-# - DATABASE_URL=postgresql://agpt_user:pass123@postgres:5432/agpt_local?connect_timeout=60
+# - DATABASE_URL=postgresql://agpt_user:pass123@postgres:5432/postgres?connect_timeout=60&schema=platform
# - NEXT_PUBLIC_AGPT_SERVER_URL=http://localhost:8006/api
# - NEXT_PUBLIC_AGPT_WS_SERVER_URL=ws://localhost:8001/ws
# - NEXT_PUBLIC_AGPT_MARKETPLACE_URL=http://localhost:8015/api/v1/market
diff --git a/autogpt_platform/docker-compose.yml b/autogpt_platform/docker-compose.yml
index 305d4104a6..be6f1f49ed 100644
--- a/autogpt_platform/docker-compose.yml
+++ b/autogpt_platform/docker-compose.yml
@@ -1,5 +1,3 @@
-version: '3.8'
-
networks:
app-network:
name: app-network
@@ -23,12 +21,6 @@ x-supabase-services:
services:
# AGPT services
- postgres:
- <<: *agpt-services
- extends:
- file: ./docker-compose.platform.yml
- service: postgres
-
migrate:
<<: *agpt-services
extends:
@@ -65,6 +57,12 @@ services:
file: ./docker-compose.platform.yml
service: market
+ market-migrations:
+ <<: *agpt-services
+ extends:
+ file: ./docker-compose.platform.yml
+ service: market-migrations
+
# frontend:
# <<: *agpt-services
# extends:
@@ -139,7 +137,6 @@ services:
extends:
file: ./supabase/docker/docker-compose.yml
service: db
-
vector:
<<: *supabase-services
extends:
diff --git a/autogpt_platform/market/.env.example b/autogpt_platform/market/.env.example
index 90935e7d6b..4b882ea674 100644
--- a/autogpt_platform/market/.env.example
+++ b/autogpt_platform/market/.env.example
@@ -1,10 +1,9 @@
-RUN_ENV=local
-DB_USER=marketplace
-DB_PASS=pass123
-DB_NAME=marketplace
+DB_USER=postgres
+DB_PASS=your-super-secret-and-long-postgres-password
+DB_NAME=postgres
DB_PORT=5432
-DATABASE_URL=postgresql://${DB_USER}:${DB_PASS}@localhost:${DB_PORT}/${DB_NAME}
-SENTRY_DSN=Set correct url or dealete me
+DATABASE_URL="postgresql://${DB_USER}:${DB_PASS}@localhost:${DB_PORT}/${DB_NAME}?connect_timeout=60&schema=marketplace"
+SENTRY_DSN=https://11d0640fef35640e0eb9f022eb7d7626@o4505260022104064.ingest.us.sentry.io/4507890252447744
ENABLE_AUTH=true
-SUPABASE_JWT_SECRET=AAAAAAAA
\ No newline at end of file
+SUPABASE_JWT_SECRET=our-super-secret-jwt-token-with-at-least-32-characters-long
\ No newline at end of file
diff --git a/docs/content/server/advanced_setup.md b/docs/content/server/advanced_setup.md
index b1d7a1a006..74b63892f9 100644
--- a/docs/content/server/advanced_setup.md
+++ b/docs/content/server/advanced_setup.md
@@ -42,13 +42,10 @@ This is useful when running on docker so you can copy the secrets into the conta
## Database selection
-### SQLite
-
-By default, the server uses SQLite as the database. SQLite is a file-based database that is easy to set up and use. However, it is not recommended for production usecases where auth is required because that subsystem requires Postgres.
### PostgreSQL
-For production use, it is recommended to use PostgreSQL as the database. You will swap the commands you use to generate and run prisma to the following
+We use a Supabase PostgreSQL as the database. You will swap the commands you use to generate and run prisma to the following
```bash
poetry run prisma generate --schema postgres/schema.prisma