From dc72ec97bceef3dd123872b8c39b05096addab2c Mon Sep 17 00:00:00 2001 From: Aarushi <50577581+aarushik93@users.noreply.github.com> Date: Wed, 18 Sep 2024 09:50:39 +0100 Subject: [PATCH] feat(rnd): Add support for supabase locally (#8077) * add just auth for now * add supabase script * add to docker compose * update docker compose * tweak(rnd) Add prefix in logs (#8001) * add prefix * fix typos * fix conflicts * feat(rnd): Reduce container size remove dep with forge and autogpt (#8040) * Remove forge and autogpt * update lock files * Update build process to reduce image size * Reduced built image size * fixed docker compose watch * Updated logging * updated env.example * formatting * linting issue * linting not working in github actions.. * trying to get around github action linting issue * updated version * sleep for prisma issues * add exp backoff on connection issues * updated config based on review comments * Sorting alphabetical * updated default config * updated depends checks * fixed missing prisma binaries * remove dead layer * remove try * remove dead layer * updated lock file * add to docker compose * update for init * add local supabase variables to docker compose * wip supbase connectioon * subabase submodule * combined docker file wth new supbase url pointing to kong * updated combined * ngix * updated docker compose without frontend * updated docker compose * update to remove frontend * update docs * update newline * remove unescessary change --------- Co-authored-by: Swifty --- .gitmodules | 3 + docs/content/server/setup.md | 15 +--- rnd/README.md | 22 ++++- rnd/docker-compose.combined.yml | 145 ++++++++++++++++++++++++++++++++ rnd/docker-compose.yml | 88 ++++++++++--------- rnd/supabase | 1 + 6 files changed, 218 insertions(+), 56 deletions(-) create mode 100644 rnd/docker-compose.combined.yml create mode 160000 rnd/supabase diff --git a/.gitmodules b/.gitmodules index aea59a8452..dd68da1d45 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "forge/tests/vcr_cassettes"] path = forge/tests/vcr_cassettes url = https://github.com/Significant-Gravitas/Auto-GPT-test-cassettes +[submodule "rnd/supabase"] + path = rnd/supabase + url = https://github.com/supabase/supabase.git diff --git a/docs/content/server/setup.md b/docs/content/server/setup.md index 2e624c05f2..3a0ca5be2a 100644 --- a/docs/content/server/setup.md +++ b/docs/content/server/setup.md @@ -102,21 +102,14 @@ poetry run prisma generate Without running this command, the necessary Python modules (prisma.models) won't be available, leading to a `ModuleNotFoundError`. -### Running the server without Docker +### Running the server To run the server, you can run the following commands in the same terminal you ran the `poetry install` command: ```bash -poetry run app -``` - -### Running the server within Docker - -To run the server, you can run the following commands in the same terminal you ran the `poetry install` command: - -```bash -docker compose build -docker compose up +cp supabase/docker/.env.example .env +docker compose -f docker-compose.combined.yml build +docker compose -f docker-compose.combined.yml up -d ``` In the other terminal from autogpt_builder, you can run the following command to start the frontend: diff --git a/rnd/README.md b/rnd/README.md index 607d1415c2..62cda7a26b 100644 --- a/rnd/README.md +++ b/rnd/README.md @@ -16,19 +16,33 @@ To run the AutoGPT Platform, follow these steps: 1. Clone this repository to your local machine. 2. Navigate to the project directory. 3. Run the following command: + ``` + cp supabase/docker/.env.example .env + ``` +4. Run the following command: ``` - docker compose up -d + docker compose -f docker-compose.combined.yml up -d + ``` - This command will start all the necessary services defined in the `docker-compose.yml` file in detached mode. + This command will start all the necessary backend services defined in the `docker-compose.combined.yml` file in detached mode. +5. Navigate to rnd/autogpt_builder. +6. Run the following command: + ``` + cp .env.example .env.local + ``` +7. Run the following command: + ``` + yarn dev + ``` ### Docker Compose Commands Here are some useful Docker Compose commands for managing your AutoGPT Platform: -- `docker compose up -d`: Start the services in detached mode. -- `docker compose stop`: Stop the running services without removing them. +- `docker compose -f docker-compose.combined.yml up -d`: Start the services in detached mode. +- `docker compose -f docker-compose.combined.yml stop`: Stop the running services without removing them. - `docker compose rm`: Remove stopped service containers. - `docker compose build`: Build or rebuild services. - `docker compose down`: Stop and remove containers, networks, and volumes. diff --git a/rnd/docker-compose.combined.yml b/rnd/docker-compose.combined.yml new file mode 100644 index 0000000000..be9d9cdcdb --- /dev/null +++ b/rnd/docker-compose.combined.yml @@ -0,0 +1,145 @@ +version: '3.8' + +networks: + app-network: + name: app-network + shared-network: + name: shared-network + +volumes: + db-config: + +x-agpt-services: + &agpt-services + networks: + - app-network + - shared-network + +x-supabase-services: + &supabase-services + networks: + - app-network + - shared-network + +services: + # AGPT services + postgres: + <<: *agpt-services + extends: + file: ./docker-compose.yml + service: postgres + + migrate: + <<: *agpt-services + extends: + file: ./docker-compose.yml + service: migrate + + redis: + <<: *agpt-services + extends: + file: ./docker-compose.yml + service: redis + + rest_server: + <<: *agpt-services + extends: + file: ./docker-compose.yml + service: rest_server + + executor: + <<: *agpt-services + extends: + file: ./docker-compose.yml + service: executor + + websocket_server: + <<: *agpt-services + extends: + file: ./docker-compose.yml + service: websocket_server + + market: + <<: *agpt-services + extends: + file: ./docker-compose.yml + service: market + +# frontend: +# <<: *agpt-services +# extends: +# file: ./docker-compose.yml +# service: frontend + + # Supabase services + studio: + <<: *supabase-services + extends: + file: ./supabase/docker/docker-compose.yml + service: studio + + kong: + <<: *supabase-services + extends: + file: ./supabase/docker/docker-compose.yml + service: kong + + auth: + <<: *supabase-services + extends: + file: ./supabase/docker/docker-compose.yml + service: auth + + rest: + <<: *supabase-services + extends: + file: ./supabase/docker/docker-compose.yml + service: rest + + realtime: + <<: *supabase-services + extends: + file: ./supabase/docker/docker-compose.yml + service: realtime + + storage: + <<: *supabase-services + extends: + file: ./supabase/docker/docker-compose.yml + service: storage + + imgproxy: + <<: *supabase-services + extends: + file: ./supabase/docker/docker-compose.yml + service: imgproxy + + meta: + <<: *supabase-services + extends: + file: ./supabase/docker/docker-compose.yml + service: meta + + functions: + <<: *supabase-services + extends: + file: ./supabase/docker/docker-compose.yml + service: functions + + analytics: + <<: *supabase-services + extends: + file: ./supabase/docker/docker-compose.yml + service: analytics + + db: + <<: *supabase-services + extends: + file: ./supabase/docker/docker-compose.yml + service: db + + vector: + <<: *supabase-services + extends: + file: ./supabase/docker/docker-compose.yml + service: vector diff --git a/rnd/docker-compose.yml b/rnd/docker-compose.yml index 1a10048b8a..0e628a0e95 100644 --- a/rnd/docker-compose.yml +++ b/rnd/docker-compose.yml @@ -11,21 +11,18 @@ services: timeout: 5s retries: 5 ports: - - "5432:5432" + - "5433:5432" networks: - app-network - + migrate: - build: - context: ../ - dockerfile: rnd/autogpt_server/Dockerfile - target: server + image: autogpt_server:latest + command: ["sh", "-c", "poetry run prisma migrate deploy"] develop: watch: - path: ./ target: rnd/autogpt_server/migrate action: rebuild - command: ["poetry", "run", "prisma", "migrate", "deploy"] depends_on: postgres: condition: service_healthy @@ -72,15 +69,18 @@ services: migrate: 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 - REDIS_HOST=redis - REDIS_PORT=6379 - REDIS_PASSWORD=password - - AUTH_ENABLED=false + - ENABLE_AUTH=true - PYRO_HOST=0.0.0.0 - EXECUTIONMANAGER_HOST=executor ports: - - "8000:8000" + - "8006:8000" - "8003:8003" # execution scheduler networks: - app-network @@ -104,11 +104,14 @@ services: migrate: condition: service_completed_successfully environment: + - 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 - REDIS_HOST=redis - REDIS_PORT=6379 - REDIS_PASSWORD=password - - AUTH_ENABLED=false + - ENABLE_AUTH=true - PYRO_HOST=0.0.0.0 - AGENTSERVER_HOST=rest_server ports: @@ -135,11 +138,14 @@ services: migrate: 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 - REDIS_HOST=redis - REDIS_PORT=6379 - REDIS_PASSWORD=password - - AUTH_ENABLED=false + - ENABLE_AUTH=true - PYRO_HOST=0.0.0.0 ports: - "8001:8001" @@ -161,40 +167,40 @@ services: migrate: condition: service_completed_successfully environment: - - DATABASE_URL=postgresql://agpt_user:pass123@postgres:5432/agpt_local?connect_timeout=60&schema=market + - 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 ports: - "8015:8015" networks: - app-network - - frontend: - build: - context: ../ - dockerfile: rnd/autogpt_builder/Dockerfile - target: dev - develop: - watch: - - path: ./ - target: rnd/autogpt_builder/ - action: rebuild - depends_on: - postgres: - condition: service_healthy - rest_server: - condition: service_started - websocket_server: - condition: service_started - migrate: - condition: service_completed_successfully - environment: - - DATABASE_URL=postgresql://agpt_user:pass123@postgres:5432/agpt_local?connect_timeout=60 - - NEXT_PUBLIC_AGPT_SERVER_URL=http://localhost:8000/api - - NEXT_PUBLIC_AGPT_WS_SERVER_URL=ws://localhost:8001/ws - - NEXT_PUBLIC_AGPT_MARKETPLACE_URL=http://localhost:8015/api/v1/market - ports: - - "3000:3000" - networks: - - app-network + +# frontend: +# build: +# context: ../ +# dockerfile: rnd/autogpt_builder/Dockerfile +# target: dev +# depends_on: +# postgres: +# condition: service_healthy +# rest_server: +# condition: service_started +# websocket_server: +# condition: service_started +# migrate: +# condition: service_completed_successfully +# 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 +# - 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 +# ports: +# - "3000:3000" +# networks: +# - app-network networks: app-network: diff --git a/rnd/supabase b/rnd/supabase new file mode 160000 index 0000000000..5e4e7d521b --- /dev/null +++ b/rnd/supabase @@ -0,0 +1 @@ +Subproject commit 5e4e7d521b4cec05a5cde83f51348a0e5f68e6a9