From 6bdd3d74d208da3ec6dbf52bd6fe963a4ad0180a Mon Sep 17 00:00:00 2001 From: dal Date: Wed, 7 May 2025 18:53:53 -0600 Subject: [PATCH] dev mode and env example update --- .env.example | 144 +++++++-------------------------------------------- Makefile | 35 +++++++++++++ api/makefile | 10 ++-- 3 files changed, 60 insertions(+), 129 deletions(-) create mode 100644 Makefile diff --git a/.env.example b/.env.example index bf3ece2a7..04012d965 100644 --- a/.env.example +++ b/.env.example @@ -1,129 +1,25 @@ -# General Application Settings +# API VARS ENVIRONMENT="development" +DATABASE_URL="postgresql://postgres:postgres@127.0.0.1:54322/postgres" +POOLER_URL="postgresql://postgres:postgres@127.0.0.1:54322/postgres" +JWT_SECRET="super-secret-jwt-token-with-at-least-32-characters-long" +REDIS_URL="redis://localhost:6379" BUSTER_URL="http://localhost:3000" BUSTER_WH_TOKEN="buster-wh-token" +LOG_LEVEL="debug" +SUPABASE_URL="http://localhost:54321" +SUPABASE_SERVICE_ROLE_KEY="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImV4cCI6MTk4MzgxMjk5Nn0.EGIM96RAZx35lJzdJsyH-qQwv8Hdp7fsn3W0YpN81IU" -# --- API Service Specific --- -# Direct Database Connection (for API service and potentially others) -DATABASE_URL="postgresql://postgres.your-tenant-id:your-super-secret-and-long-postgres-password@supavisor:5432/postgres" -# Pooled Database Connection (for API service, uses Supavisor) -POOLER_URL="postgresql://postgres.your-tenant-id:your-super-secret-and-long-postgres-password@supavisor:5432/postgres" -# Redis Connection -REDIS_URL="redis://buster-redis:6379" -# Supabase Connection for API service -SUPABASE_URL="http://kong:8000" -SUPABASE_SERVICE_ROLE_KEY="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.ey AgCiAgICAicm9sZSI6ICJzZXJ2aWNlX3JvbGUiLAogICAgImlzcyI6ICJzdXBhYmFzZS1kZW1vIiwKICAgICJpYXQiOiAxNjQxNzY5MjAwLAogICAgImV4cCI6IDE3OTk1MzU2MDAKfQ.DaYlNEoUrrEn2Ig7tqibS-PHK5vgusbcbo7X36XVt4Q" +# AI VARS +RERANK_API_KEY="your_rerank_api_key" +RERANK_MODEL="rerank-v3.5" +RERANK_BASE_URL="https://api.cohere.com/v2/rerank" +LLM_API_KEY="your_llm_api_key" +LLM_BASE_URL="http://localhost:4000" -# --- LLM / AI Services --- -EMBEDDING_PROVIDER="ollama" -EMBEDDING_MODEL="mxbai-embed-large" -COHERE_API_KEY="" -OPENAI_API_KEY="" # For OpenAI models or Supabase Studio assistant -LLM_API_KEY="test-key" -LLM_BASE_URL="http://litellm:4001" - -# --- Web Client (Next.js) Specific --- -NEXT_PUBLIC_API_URL="http://localhost:3001" # External URL for the API service (buster-api) -NEXT_PUBLIC_URL="http://localhost:3000" # External URL for the Web service (buster-web) -NEXT_PUBLIC_SUPABASE_URL="http://kong:8000" # External URL for Supabase (Kong proxy) -NEXT_PUBLIC_WS_URL="ws://localhost:3001" -NEXT_PUBLIC_SUPABASE_ANON_KEY="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.ey AgCiAgICAicm9sZSI6ICJhbm9uIiwKICAgICJpc3MiOiAic3VwYWJhc2UtZGVtbyIsCiAgICAiaWF0IjogMTY0MTc2OTIwMCwKICAgICJleHAiOiAxNzk5NTM1NjAwCn0.dc_X5iR_VP_qT0zsiyj_I_OZ2T9FtRU2BBNWN8Bu4GE" -NEXT_PRIVATE_SUPABASE_SERVICE_ROLE_KEY="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.ey AgCiAgICAicm9sZSI6ICJzZXJ2aWNlX3JvbGUiLAogICAgImlzcyI6ICJzdXBhYmFzZS1kZW1vIiwKICAgICJpYXQiOiAxNjQxNzY5MjAwLAogICAgImV4cCI6IDE3OTk1MzU2MDAKfQ.DaYlNEoUrrEn2Ig7tqibS-PHK5vgusbcbo7X36XVt4Q" - -################################################# -# Supabase Stack Configuration Variables -# These are primarily used by the Supabase services themselves -# (defined in supabase/docker-compose.yml) -# and are sourced from this .env file when `docker compose up` is run. -################################################# - -############ -# Secrets -############ -POSTGRES_PASSWORD="your-super-secret-and-long-postgres-password" -JWT_SECRET="your-super-secret-jwt-token-with-at-least-32-characters-long" -ANON_KEY="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.ey AgCiAgICAicm9sZSI6ICJhbm9uIiwKICAgICJpc3MiOiAic3VwYWJhc2UtZGVtbyIsCiAgICAiaWF0IjogMTY0MTc2OTIwMCwKICAgICJleHAiOiAxNzk5NTM1NjAwCn0.dc_X5iR_VP_qT0zsiyj_I_OZ2T9FtRU2BBNWN8Bu4GE" -SERVICE_ROLE_KEY="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.ey AgCiAgICAicm9sZSI6ICJzZXJ2aWNlX3JvbGUiLAogICAgImlzcyI6ICJzdXBhYmFzZS1kZW1vIiwKICAgICJpYXQiOiAxNjQxNzY5MjAwLAogICAgImV4cCI6IDE3OTk1MzU2MDAKfQ.DaYlNEoUrrEn2Ig7tqibS-PHK5vgusbcbo7X36XVt4Q" -DASHBOARD_USERNAME="supabase" -DASHBOARD_PASSWORD="this_password_is_insecure_and_should_be_updated" - -############ -# Database -############ -POSTGRES_HOST="db" -POSTGRES_DB="postgres" -POSTGRES_PORT="5432" - -############ -# Supavisor -- Database pooler -############ -POOLER_PROXY_PORT_TRANSACTION="6543" -POOLER_DEFAULT_POOL_SIZE="20" -POOLER_MAX_CLIENT_CONN="100" -POOLER_TENANT_ID="your-tenant-id" - -############ -# API Proxy - Kong -############ -KONG_HTTP_PORT="8000" -KONG_HTTPS_PORT="8443" - -############ -# API - PostgREST -############ -PGRST_DB_SCHEMAS="public,storage,graphql_public" - -############ -# Auth - GoTrue -############ -SITE_URL="http://localhost:3000" # Default base URL for the site (used in emails, etc.) -ADDITIONAL_REDIRECT_URLS="" -JWT_EXPIRY="3600" -DISABLE_SIGNUP="false" -API_EXTERNAL_URL="http://localhost:8000" # Publicly accessible URL for the Supabase API (via Kong) - -## Mailer Config -MAILER_URLPATHS_CONFIRMATION="/auth/v1/verify" -MAILER_URLPATHS_INVITE="/auth/v1/verify" -MAILER_URLPATHS_RECOVERY="/auth/v1/verify" -MAILER_URLPATHS_EMAIL_CHANGE="/auth/v1/verify" - -## Email auth -ENABLE_EMAIL_SIGNUP="true" -ENABLE_EMAIL_AUTOCONFIRM="false" -SMTP_ADMIN_EMAIL="admin@buster.so" -SMTP_HOST="supabase-mail" -SMTP_PORT="2500" -SMTP_USER="" -SMTP_PASS="" -SMTP_SENDER_NAME="Buster" -ENABLE_ANONYMOUS_USERS="true" - -## Phone auth -ENABLE_PHONE_SIGNUP="true" -ENABLE_PHONE_AUTOCONFIRM="true" - -############ -# Studio - Supabase Dashboard -############ -STUDIO_DEFAULT_ORGANIZATION="Default Organization" -STUDIO_DEFAULT_PROJECT="Default Project" -STUDIO_PORT="3003" -SUPABASE_PUBLIC_URL="http://localhost:8000" # Public URL for Supabase (Kong), used by Studio - -# Image Proxy -IMGPROXY_ENABLE_WEBP_DETECTION="true" - -############ -# Functions - Supabase Edge Functions -############ -FUNCTIONS_VERIFY_JWT="false" - -############ -# Logs - Logflare -############ -LOGFLARE_LOGGER_BACKEND_API_KEY="your-super-secret-and-long-logflare-key" -LOGFLARE_API_KEY="your-super-secret-and-long-logflare-key" -DOCKER_SOCKET_LOCATION="/var/run/docker.sock" -GOOGLE_PROJECT_ID="GOOGLE_PROJECT_ID" -GOOGLE_PROJECT_NUMBER="GOOGLE_PROJECT_NUMBER" \ No newline at end of file +# WEB VARS +NEXT_PUBLIC_API_URL="http://127.0.0.1:3001" +NEXT_PUBLIC_URL="http://localhost:3000" +NEXT_PUBLIC_SUPABASE_URL="http://127.0.0.1:54321" +NEXT_PUBLIC_SUPABASE_ANON_KEY="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0" +NEXT_PUBLIC_WEB_SOCKET_URL="ws://127.0.0.1:3001" \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..6369431ba --- /dev/null +++ b/Makefile @@ -0,0 +1,35 @@ +# Makefile (root) + +.PHONY: dev api-dev-fg web-dev-fg stop + +# Main development target: runs both API and Web dev servers in parallel. +# They will run until Ctrl+C is pressed. +dev: + @echo "Starting API and Web development servers..." + @echo "Press Ctrl+C to stop all." + # Start API dev server in the background + # The subshell ( ... ) ensures that 'cd' doesn't affect subsequent commands at this level. + (cd api && $(MAKE) dev) & \ + # Start Web dev server in the background + (cd web && $(MAKE) dev) & \ + # Wait for all background jobs of this shell to complete. + # Since dev servers run indefinitely, this 'wait' will also run indefinitely until interrupted (Ctrl+C). + wait + @echo "Development servers stopped or shell command finished." + +# Target to stop API-specific services (like Docker containers, Supabase). +# The web dev server (npm run dev) is expected to be stopped when 'make dev' is interrupted (Ctrl+C). +stop: + @echo "Stopping API services (Redis, Supabase)..." + $(MAKE) -C api stop + @echo "API services stopped. If 'make dev' was running, web server should also be stopped." + +# Individual targets if you want to run them separately (e.g., in different terminal tabs) +# These are foreground targets. +api-dev-fg: + @echo "Starting API development server (foreground)..." + cd api && $(MAKE) dev + +web-dev-fg: + @echo "Starting Web development server (foreground)..." + cd web && $(MAKE) dev \ No newline at end of file diff --git a/api/makefile b/api/makefile index 1505fbf1b..885fd4d49 100644 --- a/api/makefile +++ b/api/makefile @@ -1,5 +1,5 @@ dev: - cd .. && docker compose up -d redis && cd api && \ + cd .. && docker run -d --name buster-redis-make -p 6379:6379 -v buster_redis_data:/data redis && cd api && \ supabase start supabase db reset export DATABASE_URL=postgres://postgres:postgres@127.0.0.1:54322/postgres && \ @@ -21,12 +21,12 @@ update-seed: > libs/database/seed.sql stop: - docker compose down && \ - supabase stop && \ - pkill ollama + docker stop buster-redis-make || true && \ + docker rm buster-redis-make || true && \ + cd .. && docker compose down && supabase stop fast: - cd .. && docker compose up -d redis && cd api && \ + cd .. && docker run -d --name buster-redis-make -p 6379:6379 -v buster_redis_data:/data redis && cd api && \ export RUST_LOG=debug && \ export CARGO_INCREMENTAL=1 && \ nice cargo watch -C server -x run \ No newline at end of file