From 260009e8cb8c9538a7031c1ed2b41bbc9ccf6572 Mon Sep 17 00:00:00 2001 From: MarkLo Date: Fri, 21 Nov 2025 08:22:18 +0800 Subject: [PATCH] --- .python-version | 2 +- DEPLOY.md | 5 +- deploy.sh | 178 ------------------------------------------------ render.yaml | 2 +- 4 files changed, 6 insertions(+), 181 deletions(-) delete mode 100755 deploy.sh diff --git a/.python-version b/.python-version index c8cfe395..2419ad5b 100644 --- a/.python-version +++ b/.python-version @@ -1 +1 @@ -3.10 +3.11.9 diff --git a/DEPLOY.md b/DEPLOY.md index d5206587..80b7b8cb 100644 --- a/DEPLOY.md +++ b/DEPLOY.md @@ -84,9 +84,12 @@ Start Command: uvicorn app.main:app --host 0.0.0.0 --port $PORT OPENAI_API_KEY=your_openai_api_key_here ALPHA_VANTAGE_API_KEY=your_alpha_vantage_key_here TRADINGAGENTS_RESULTS_DIR=/opt/render/project/src/results -PYTHON_VERSION=3.11 +PYTHON_VERSION=3.11.9 ``` +> [!IMPORTANT] +> Render 要求 `PYTHON_VERSION` 必須是完整的版本號(例如 `3.11.9`),不能只是 `3.11`。 + #### 1.5 選擇免費方案 - Instance Type: **Free** - 點擊 "Create Web Service" diff --git a/deploy.sh b/deploy.sh deleted file mode 100755 index 673e57b6..00000000 --- a/deploy.sh +++ /dev/null @@ -1,178 +0,0 @@ -#!/bin/bash - -# TradingAgents Deployment Helper Script -# This script helps prepare your project for deployment - -set -e - -echo "🚀 TradingAgents Deployment Helper" -echo "==================================" -echo "" - -# Check if .env file exists -if [ ! -f .env ]; then - echo "⚠️ No .env file found. Creating from .env.example..." - cp .env.example .env - echo "✅ Created .env file. Please edit it with your API keys." - echo "" -fi - -# Function to check if API key is set -check_api_key() { - local key_name=$1 - local key_value=$(grep "^${key_name}=" .env | cut -d '=' -f2) - - local key_placeholder=$(echo "$key_name" | tr '[:upper:]' '[:lower:]')_placeholder - - if [ -z "$key_value" ] || [ "$key_value" = "$key_placeholder" ]; then - echo "❌ $key_name is not set" - return 1 - else - echo "✅ $key_name is set" - return 0 - fi -} - -echo "Checking required API keys..." -echo "" - -# Check required keys -OPENAI_OK=false -ALPHA_OK=false - -if check_api_key "OPENAI_API_KEY"; then - OPENAI_OK=true -fi - -if check_api_key "ALPHA_VANTAGE_API_KEY"; then - ALPHA_OK=true -fi - -echo "" - -if [ "$OPENAI_OK" = false ] || [ "$ALPHA_OK" = false ]; then - echo "⚠️ API keys are missing in .env file." - echo " You can proceed if you intend to use BYOK (Bring Your Own Key) mode," - echo " where users must enter their keys in the frontend." - echo "" - read -p "Do you want to proceed with BYOK mode? (y/n) " -n 1 -r - echo "" - if [[ ! $REPLY =~ ^[Yy]$ ]]; then - echo "Please set the required API keys in .env file before deploying." - exit 1 - fi -fi - -echo "✅ All required API keys are configured!" -echo "" - -# Display deployment options -echo "📦 Deployment Options:" -echo "" -echo "1. Vercel (Frontend) + Render (Backend) - FREE" -echo " - Best for: Personal projects, testing" -echo " - See DEPLOY.md for detailed instructions" -echo "" -echo "2. Railway - FREE tier available" -echo " - Best for: All-in-one deployment" -echo " - See DEPLOY.md for detailed instructions" -echo "" -echo "3. Docker Compose - Self-hosted" -echo " - Best for: VPS deployment" -echo " - Run: docker-compose up -d" -echo "" - -# Ask user which deployment method -echo "Which deployment method would you like to use?" -echo "1) Vercel + Render (Recommended for free)" -echo "2) Railway" -echo "3) Docker Compose" -echo "4) Just show me the guide" -read -p "Enter your choice (1-4): " choice - -case $choice in - 1) - echo "" - echo "📖 Vercel + Render Deployment" - echo "==============================" - echo "" - echo "Step 1: Deploy Backend to Render" - echo " 1. Go to https://render.com and sign in with GitHub" - echo " 2. Click 'New +' → 'Web Service'" - echo " 3. Connect your repository" - echo " 4. Configure:" - echo " - Root Directory: backend" - echo " - Build Command: pip install -r requirements.txt" - echo " - Start Command: uvicorn app.main:app --host 0.0.0.0 --port \$PORT" - echo " 5. Add environment variables from your .env file" - echo " 6. Deploy!" - echo "" - echo "Step 2: Deploy Frontend to Vercel" - echo " 1. Go to https://vercel.com and sign in with GitHub" - echo " 2. Click 'Add New...' → 'Project'" - echo " 3. Select your repository" - echo " 4. Configure:" - echo " - Root Directory: frontend" - echo " - Framework: Next.js" - echo " 5. Add environment variable:" - echo " NEXT_PUBLIC_API_URL=" - echo " 6. Deploy!" - echo "" - echo "📚 For detailed instructions, see DEPLOY.md" - ;; - 2) - echo "" - echo "📖 Railway Deployment" - echo "====================" - echo "" - echo "1. Go to https://railway.app and sign in with GitHub" - echo "2. Click 'New Project' → 'Deploy from GitHub repo'" - echo "3. Select your repository" - echo "4. Add two services (Backend and Frontend)" - echo "5. Configure environment variables" - echo "" - echo "📚 For detailed instructions, see DEPLOY.md" - ;; - 3) - echo "" - echo "📖 Docker Compose Deployment" - echo "============================" - echo "" - echo "Running Docker Compose..." - if command -v docker-compose &> /dev/null; then - docker-compose up -d - echo "" - echo "✅ Services started!" - echo " - Frontend: http://localhost:3000" - echo " - Backend: http://localhost:8000" - echo "" - echo "To view logs: docker-compose logs -f" - echo "To stop: docker-compose down" - else - echo "❌ docker-compose not found. Please install Docker first." - echo " Visit: https://docs.docker.com/get-docker/" - fi - ;; - 4) - echo "" - echo "📚 Opening deployment guide..." - if [ -f "DEPLOY.md" ]; then - if command -v open &> /dev/null; then - open DEPLOY.md - elif command -v xdg-open &> /dev/null; then - xdg-open DEPLOY.md - else - cat DEPLOY.md - fi - else - echo "❌ DEPLOY.md not found" - fi - ;; - *) - echo "Invalid choice. Please run the script again." - exit 1 - ;; -esac - -echo "" -echo "🎉 Good luck with your deployment!" diff --git a/render.yaml b/render.yaml index c5dec284..1e25714b 100644 --- a/render.yaml +++ b/render.yaml @@ -9,7 +9,7 @@ services: startCommand: uvicorn app.main:app --host 0.0.0.0 --port $PORT envVars: - key: PYTHON_VERSION - value: 3.11 + value: 3.11.9 - key: OPENAI_API_KEY sync: false - key: ALPHA_VANTAGE_API_KEY