From b441c32ae0838625b3c1deccfe8c1d5031b81392 Mon Sep 17 00:00:00 2001 From: dal Date: Thu, 8 May 2025 03:45:34 -0600 Subject: [PATCH] cli test --- .env.example | 23 +++++----- .github/workflows/cli-release.yml | 2 +- cli/cli/src/commands/run.rs | 72 +++++++++++++++---------------- supabase/.env.example | 8 ---- 4 files changed, 48 insertions(+), 57 deletions(-) diff --git a/.env.example b/.env.example index 7133a3dd4..575f865eb 100644 --- a/.env.example +++ b/.env.example @@ -1,14 +1,14 @@ # API VARS ENVIRONMENT="local" -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" +JWT_SECRET="super-secret-jwt-token-with-at-least-32-characters-long" BUSTER_WH_TOKEN="buster-wh-token" +DATABASE_URL="postgresql://postgres.your-tenant-id:your-super-secret-and-long-postgres-password@supavisor:5432/postgres" +POOLER_URL="postgresql://postgres.your-tenant-id:your-super-secret-and-long-postgres-password@supavisor:5432/postgres" +REDIS_URL="redis://buster-redis:6379" LOG_LEVEL="debug" -SUPABASE_URL="http://localhost:54321" -SUPABASE_SERVICE_ROLE_KEY="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImV4cCI6MTk4MzgxMjk5Nn0.EGIM96RAZx35lJzdJsyH-qQwv8Hdp7fsn3W0YpN81IU" +SUPABASE_URL="http://kong:8000" +SUPABASE_SERVICE_ROLE_KEY="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.ey AgCiAgICAicm9sZSI6ICJzZXJ2aWNlX3JvbGUiLAogICAgImlzcyI6ICJzdXBhYmFzZS1kZW1vIiwKICAgICJpYXQiOiAxNjQxNzY5MjAwLAogICAgImV4cCI6IDE3OTk1MzU2MDAKfQ.DaYlNEoUrrEn2Ig7tqibS-PHK5vgusbcbo7X36XVt4Q" # AI VARS RERANK_API_KEY="your_rerank_api_key" @@ -18,8 +18,9 @@ LLM_API_KEY="your_llm_api_key" LLM_BASE_URL="https://api.openai.com/v1" # 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 +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" \ No newline at end of file diff --git a/.github/workflows/cli-release.yml b/.github/workflows/cli-release.yml index 2ede9361d..f532ee4e3 100644 --- a/.github/workflows/cli-release.yml +++ b/.github/workflows/cli-release.yml @@ -130,7 +130,7 @@ jobs: - name: Extract version from Cargo.toml id: get_version run: | - VERSION=$(grep '^version =' cli/cli/Cargo.toml | sed 's/version = "\(.*\)"/\1/') + VERSION=$(awk -F'"' '/^version =/ {print $2}' cli/cli/Cargo.toml) echo "version=$VERSION" >> $GITHUB_OUTPUT echo "Extracted version: $VERSION" - name: Create Release diff --git a/cli/cli/src/commands/run.rs b/cli/cli/src/commands/run.rs index 510776105..e31226543 100644 --- a/cli/cli/src/commands/run.rs +++ b/cli/cli/src/commands/run.rs @@ -70,14 +70,14 @@ async fn setup_persistent_app_environment() -> Result { )) })?; - // Initialize .env from .env.example (the one at app_base_dir), which should have been extracted by StaticAssets loop + // Initialize .env from .env.example (the root one), which should have been extracted by StaticAssets loop let example_env_src_path = app_base_dir.join(".env.example"); - let main_dot_env_target_path = app_base_dir.join(".env"); + let main_dot_env_target_path = app_base_dir.join(".env"); // This is the root .env if example_env_src_path.exists() { fs::copy(&example_env_src_path, &main_dot_env_target_path).map_err(|e| { BusterError::CommandError(format!( - "Failed to initialize {} from {}: {}", + "Failed to initialize root .env ({}) from {}: {}", main_dot_env_target_path.display(), example_env_src_path.display(), e @@ -85,14 +85,31 @@ async fn setup_persistent_app_environment() -> Result { })?; } else { // This case should ideally not be hit if .env.example is correctly embedded and extracted. - // If it's missing, it indicates an issue with asset handling. return Err(BusterError::CommandError(format!( - "Critical setup error: {} not found after asset extraction. Cannot initialize main .env file.", + "Critical setup error: Root {} not found after asset extraction. Cannot initialize main .env file.", example_env_src_path.display() ))); } - let target_dotenv_path = app_base_dir.join(".env"); + // Initialize supabase/.env from supabase/.env.example + let supabase_example_env_src_path = app_base_dir.join("supabase/.env.example"); + let supabase_dot_env_target_path = app_base_dir.join("supabase/.env"); + + if supabase_example_env_src_path.exists() { + fs::copy(&supabase_example_env_src_path, &supabase_dot_env_target_path).map_err(|e| { + BusterError::CommandError(format!( + "Failed to initialize supabase/.env ({}) from {}: {}", + supabase_dot_env_target_path.display(), + supabase_example_env_src_path.display(), + e + )) + })?; + } else { + return Err(BusterError::CommandError(format!( + "Critical setup error: Supabase {} not found after asset extraction. Cannot initialize supabase/.env file.", + supabase_example_env_src_path.display() + ))); + } // --- BEGIN API Key and Reranker Setup using config_utils --- println!("--- Buster Configuration Setup ---"); @@ -100,9 +117,9 @@ async fn setup_persistent_app_environment() -> Result { let llm_api_key = config_utils::prompt_and_manage_openai_api_key(&app_base_dir, false)?; let reranker_config = config_utils::prompt_and_manage_reranker_settings(&app_base_dir, false)?; - // Update .env file + // Update .env file (this is the root .env) config_utils::update_env_file( - &target_dotenv_path, + &main_dot_env_target_path, // Ensure this targets the root .env Some(&llm_api_key), Some(&reranker_config.api_key), Some(&reranker_config.model), @@ -112,7 +129,7 @@ async fn setup_persistent_app_environment() -> Result { .map_err(|e| { BusterError::CommandError(format!( "Failed to ensure .env file configurations in {}: {}", - target_dotenv_path.display(), + main_dot_env_target_path.display(), // Use root .env path here e )) })?; @@ -120,17 +137,6 @@ async fn setup_persistent_app_environment() -> Result { println!("--- Configuration Setup Complete ---"); // --- END API Key and Reranker Setup using config_utils --- - // Additionally copy the .env to the supabase subdirectory - let supabase_dotenv_path = app_base_dir.join("supabase/.env"); - fs::copy(&target_dotenv_path, &supabase_dotenv_path).map_err(|e| { - BusterError::CommandError(format!( - "Failed to copy .env from {} to {}: {}", - target_dotenv_path.display(), - supabase_dotenv_path.display(), - e - )) - })?; - Ok(app_base_dir) } @@ -313,13 +319,10 @@ Stderr: String::from_utf8_lossy(&down_output.stdout), String::from_utf8_lossy(&down_output.stderr) ); - pb.abandon_with_message("Error: docker compose down failed. See console for details."); - println!(" -Docker Compose Down Error Details: -{}", err_msg); - return Err(BusterError::CommandError(err_msg)); + pb.println(format!("Warning: {} - Proceeding with reset.", err_msg)); + } else { + pb.println("Services stopped successfully."); } - pb.println("Services stopped successfully."); // Step 2: Identify and Remove service images @@ -341,6 +344,8 @@ Docker Compose Down Error Details: e )) })?; + + let mut image_list_str; if !config_images_output.status.success() { let err_msg = format!( "docker compose config --images failed (status: {}). Logs: @@ -354,19 +359,12 @@ Stderr: String::from_utf8_lossy(&config_images_output.stdout), String::from_utf8_lossy(&config_images_output.stderr) ); - pb.abandon_with_message( - "Error: Failed to identify service images. See console for details.", - ); - println!( - " -Docker Compose Config --images Error Details: -{}", - err_msg - ); - return Err(BusterError::CommandError(err_msg)); + pb.println(format!("Warning: {} - Skipping image removal and proceeding with reset.", err_msg)); + image_list_str = String::new(); // Ensure image_names is empty + } else { + image_list_str = String::from_utf8_lossy(&config_images_output.stdout).to_string(); } - let image_list_str = String::from_utf8_lossy(&config_images_output.stdout); let image_names: Vec<&str> = image_list_str .lines() .filter(|line| !line.trim().is_empty()) diff --git a/supabase/.env.example b/supabase/.env.example index d2cb2c943..165bea8bc 100644 --- a/supabase/.env.example +++ b/supabase/.env.example @@ -14,14 +14,6 @@ REDIS_URL="redis://buster-redis:6379" SUPABASE_URL="http://kong:8000" SUPABASE_SERVICE_ROLE_KEY="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.ey AgCiAgICAicm9sZSI6ICJzZXJ2aWNlX3JvbGUiLAogICAgImlzcyI6ICJzdXBhYmFzZS1kZW1vIiwKICAgICJpYXQiOiAxNjQxNzY5MjAwLAogICAgImV4cCI6IDE3OTk1MzU2MDAKfQ.DaYlNEoUrrEn2Ig7tqibS-PHK5vgusbcbo7X36XVt4Q" -# --- 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://buster-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)