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

* move to supabase pg instance

* remove postgres and bind supabase port

* Updated setup
- Switched db name to postgres to work with prisma studio
- Added platform schema
- Added Market-migartions
- bound prisma studio port

* remove studio port

* updated .env

* updated readmes

---------

Co-authored-by: SwiftyOS <craigswift13@gmail.com>
pull/8137/head^2
Aarushi 2024-09-23 14:04:26 +01:00 committed by GitHub
parent c533044cdc
commit 88e278b736
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 53 additions and 56 deletions

View File

@ -1,8 +1,8 @@
DB_USER=agpt_user DB_USER=postgres
DB_PASS=pass123 DB_PASS=your-super-secret-and-long-postgres-password
DB_NAME=agpt_local DB_NAME=postgres
DB_PORT=5433 DB_PORT=5432
DATABASE_URL="postgresql://${DB_USER}:${DB_PASS}@localhost:${DB_PORT}/${DB_NAME}" DATABASE_URL="postgresql://${DB_USER}:${DB_PASS}@localhost:${DB_PORT}/${DB_NAME}?connect_timeout=60&schema=platform"
PRISMA_SCHEMA="postgres/schema.prisma" PRISMA_SCHEMA="postgres/schema.prisma"
REDIS_HOST=localhost REDIS_HOST=localhost
@ -15,7 +15,7 @@ APP_ENV="local"
PYRO_HOST=localhost PYRO_HOST=localhost
SENTRY_DSN= SENTRY_DSN=
# This is needed when ENABLE_AUTH is true # 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 ===== ## ## ===== OPTIONAL API KEYS ===== ##

View File

@ -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. 6. Migrate the database. Be careful because this deletes current data in the database.
```sh ```sh
docker compose up postgres redis -d docker compose up db redis -d
poetry run prisma migrate dev poetry run prisma migrate dev
``` ```

View File

@ -1,20 +1,4 @@
services: 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: migrate:
build: build:
context: ../ context: ../
@ -27,10 +11,10 @@ services:
target: autogpt_platform/backend/migrate target: autogpt_platform/backend/migrate
action: rebuild action: rebuild
depends_on: depends_on:
postgres: db:
condition: service_healthy condition: service_healthy
environment: 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: networks:
- app-network - app-network
restart: on-failure restart: on-failure
@ -67,7 +51,7 @@ services:
depends_on: depends_on:
redis: redis:
condition: service_healthy condition: service_healthy
postgres: db:
condition: service_healthy condition: service_healthy
migrate: migrate:
condition: service_completed_successfully condition: service_completed_successfully
@ -75,7 +59,7 @@ services:
- SUPABASE_URL=http://kong:8000 - SUPABASE_URL=http://kong:8000
- SUPABASE_JWT_SECRET=your-super-secret-jwt-token-with-at-least-32-characters-long - 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 - 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_HOST=redis
- REDIS_PORT=6379 - REDIS_PORT=6379
- REDIS_PASSWORD=password - REDIS_PASSWORD=password
@ -102,7 +86,7 @@ services:
depends_on: depends_on:
redis: redis:
condition: service_healthy condition: service_healthy
postgres: db:
condition: service_healthy condition: service_healthy
migrate: migrate:
condition: service_completed_successfully condition: service_completed_successfully
@ -110,7 +94,7 @@ services:
- NEXT_PUBLIC_SUPABASE_URL=http://kong:8000 - NEXT_PUBLIC_SUPABASE_URL=http://kong:8000
- SUPABASE_JWT_SECRET=your-super-secret-jwt-token-with-at-least-32-characters-long - 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 - 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_HOST=redis
- REDIS_PORT=6379 - REDIS_PORT=6379
- REDIS_PASSWORD=password - REDIS_PASSWORD=password
@ -134,7 +118,7 @@ services:
target: autogpt_platform/backend/ target: autogpt_platform/backend/
action: rebuild action: rebuild
depends_on: depends_on:
postgres: db:
condition: service_healthy condition: service_healthy
redis: redis:
condition: service_healthy condition: service_healthy
@ -144,7 +128,7 @@ services:
- SUPABASE_URL=http://kong:8000 - SUPABASE_URL=http://kong:8000
- SUPABASE_JWT_SECRET=your-super-secret-jwt-token-with-at-least-32-characters-long - 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 - 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_HOST=redis
- REDIS_PORT=6379 - REDIS_PORT=6379
- REDIS_PASSWORD=password - REDIS_PASSWORD=password
@ -165,27 +149,47 @@ services:
target: autogpt_platform/market/ target: autogpt_platform/market/
action: rebuild action: rebuild
depends_on: depends_on:
postgres: db:
condition: service_healthy condition: service_healthy
migrate: market-migrations:
condition: service_completed_successfully condition: service_completed_successfully
environment: environment:
- SUPABASE_URL=http://kong:8000 - SUPABASE_URL=http://kong:8000
- SUPABASE_JWT_SECRET=your-super-secret-jwt-token-with-at-least-32-characters-long - 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 - 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: ports:
- "8015:8015" - "8015:8015"
networks: networks:
- app-network - 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: # frontend:
# build: # build:
# context: ../ # context: ../
# dockerfile: autogpt_platform/frontend/Dockerfile # dockerfile: autogpt_platform/frontend/Dockerfile
# target: dev # target: dev
# depends_on: # depends_on:
# postgres: # db:
# condition: service_healthy # condition: service_healthy
# rest_server: # rest_server:
# condition: service_started # condition: service_started
@ -196,7 +200,7 @@ services:
# environment: # environment:
# - NEXT_PUBLIC_SUPABASE_URL=http://kong:8000 # - NEXT_PUBLIC_SUPABASE_URL=http://kong:8000
# - NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJhbm9uIiwKICAgICJpc3MiOiAic3VwYWJhc2UtZGVtbyIsCiAgICAiaWF0IjogMTY0MTc2OTIwMCwKICAgICJleHAiOiAxNzk5NTM1NjAwCn0.dc_X5iR_VP_qT0zsiyj_I_OZ2T9FtRU2BBNWN8Bu4GE # - 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_SERVER_URL=http://localhost:8006/api
# - NEXT_PUBLIC_AGPT_WS_SERVER_URL=ws://localhost:8001/ws # - NEXT_PUBLIC_AGPT_WS_SERVER_URL=ws://localhost:8001/ws
# - NEXT_PUBLIC_AGPT_MARKETPLACE_URL=http://localhost:8015/api/v1/market # - NEXT_PUBLIC_AGPT_MARKETPLACE_URL=http://localhost:8015/api/v1/market

View File

@ -1,5 +1,3 @@
version: '3.8'
networks: networks:
app-network: app-network:
name: app-network name: app-network
@ -23,12 +21,6 @@ x-supabase-services:
services: services:
# AGPT services # AGPT services
postgres:
<<: *agpt-services
extends:
file: ./docker-compose.platform.yml
service: postgres
migrate: migrate:
<<: *agpt-services <<: *agpt-services
extends: extends:
@ -65,6 +57,12 @@ services:
file: ./docker-compose.platform.yml file: ./docker-compose.platform.yml
service: market service: market
market-migrations:
<<: *agpt-services
extends:
file: ./docker-compose.platform.yml
service: market-migrations
# frontend: # frontend:
# <<: *agpt-services # <<: *agpt-services
# extends: # extends:
@ -139,7 +137,6 @@ services:
extends: extends:
file: ./supabase/docker/docker-compose.yml file: ./supabase/docker/docker-compose.yml
service: db service: db
vector: vector:
<<: *supabase-services <<: *supabase-services
extends: extends:

View File

@ -1,10 +1,9 @@
RUN_ENV=local DB_USER=postgres
DB_USER=marketplace DB_PASS=your-super-secret-and-long-postgres-password
DB_PASS=pass123 DB_NAME=postgres
DB_NAME=marketplace
DB_PORT=5432 DB_PORT=5432
DATABASE_URL=postgresql://${DB_USER}:${DB_PASS}@localhost:${DB_PORT}/${DB_NAME} DATABASE_URL="postgresql://${DB_USER}:${DB_PASS}@localhost:${DB_PORT}/${DB_NAME}?connect_timeout=60&schema=marketplace"
SENTRY_DSN=Set correct url or dealete me SENTRY_DSN=https://11d0640fef35640e0eb9f022eb7d7626@o4505260022104064.ingest.us.sentry.io/4507890252447744
ENABLE_AUTH=true ENABLE_AUTH=true
SUPABASE_JWT_SECRET=AAAAAAAA SUPABASE_JWT_SECRET=our-super-secret-jwt-token-with-at-least-32-characters-long

View File

@ -42,13 +42,10 @@ This is useful when running on docker so you can copy the secrets into the conta
## Database selection ## 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 ### 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 ```bash
poetry run prisma generate --schema postgres/schema.prisma poetry run prisma generate --schema postgres/schema.prisma