one step self deployment setup

This commit is contained in:
Ravi Sojitra 2025-05-13 21:10:25 +05:30
parent 49e0f2ea8c
commit 79209cb087
3 changed files with 278 additions and 182 deletions

194
README.md
View File

@ -26,10 +26,8 @@ Suna's powerful toolkit includes seamless browser automation to navigate the web
- [Frontend](#frontend)
- [Agent Docker](#agent-docker)
- [Supabase Database](#supabase-database)
- [Run Locally / Self-Hosting](#run-locally--self-hosting)
- [Requirements](#requirements)
- [Prerequisites](#prerequisites)
- [Installation Steps](#installation-steps)
- [Use Cases](#use-cases)
- [Self-Hosting](#self-hosting)
- [Acknowledgements](#acknowledgements)
- [License](#license)
@ -77,58 +75,19 @@ Handles data persistence with authentication, user management, conversation hist
12. **Scrape Forum Discussions** ([Watch](https://www.suna.so/share/7d7a5d93-a20d-48b0-82cc-e9a876e9fd04)) - *"I need to find the best beauty centers in Rome, but I want to find them by using open forums that speak about this topic. Go on Google, and scrape the forums by looking for beauty center discussions located in Rome. Then generate a list of 5 beauty centers with the best comments about them."*
## Run Locally / Self-Hosting
## Self-Hosting
Suna can be self-hosted on your own infrastructure. Follow these steps to set up your own instance.
Suna can be self-hosted on your own infrastructure using our setup wizard. For a comprehensive guide to self-hosting Suna, please refer to our [Self-Hosting Guide](./SELF-HOSTING.md).
### Requirements
The setup process includes:
You'll need the following components:
- A Supabase project for database and authentication
- Redis database for caching and session management
- Daytona sandbox for secure agent execution
- Python 3.11 for the API backend
- API keys for LLM providers (Anthropic, OpenRouter)
- Tavily API key for enhanced search capabilities
- Firecrawl API key for web scraping capabilities
- Setting up a Supabase project for database and authentication
- Configuring Redis for caching and session management
- Setting up Daytona for secure agent execution
- Integrating with LLM providers (Anthropic, OpenAI, Groq, etc.)
- Configuring web search and scraping capabilities
### Prerequisites
1. **Supabase**:
- Create a new [Supabase project](https://supabase.com/dashboard/projects)
- Save your project's API URL, anon key, and service role key for later use
- Install the [Supabase CLI](https://supabase.com/docs/guides/cli/getting-started)
2. **Redis**:
- Go to the `/backend` folder
- Run `docker compose up redis`
3. **Daytona**:
- Create an account on [Daytona](https://app.daytona.io/)
- Generate an API key from your account settings
- Go to [Images](https://app.daytona.io/dashboard/images)
- Click "Add Image"
- Enter `kortix/suna:0.1` as the image name
- Set `/usr/bin/supervisord -n -c /etc/supervisor/conf.d/supervisord.conf` as the Entrypoint
4. **LLM API Keys**:
- Obtain an API key [Anthropic](https://www.anthropic.com/)
- While other providers should work via [LiteLLM](https://github.com/BerriAI/litellm), Anthropic is recommended the prompt needs to be adjusted for other providers to output correct XML for tool calls.
5. **Search API Key** (Optional):
- For enhanced search capabilities, obtain an [Tavily API key](https://tavily.com/)
- For web scraping capabilities, obtain a [Firecrawl API key](https://firecrawl.dev/)
6. **RapidAPI API Key** (Optional):
- To enable API services like LinkedIn, and others, you'll need a RapidAPI key
- Each service requires individual activation in your RapidAPI account:
1. Locate the service's `base_url` in its corresponding file (e.g., `"https://linkedin-data-scraper.p.rapidapi.com"` in [`backend/agent/tools/data_providers/LinkedinProvider.py`](backend/agent/tools/data_providers/LinkedinProvider.py))
2. Visit that specific API on the RapidAPI marketplace
3. Subscribe to the service (many offer free tiers with limited requests)
4. Once subscribed, the service will be available to your agent through the API Services tool
### Installation Steps
### Quick Start
1. **Clone the repository**:
```bash
@ -136,134 +95,12 @@ git clone https://github.com/kortix-ai/suna.git
cd suna
```
2. **Configure backend environment**:
2. **Run the setup wizard**:
```bash
cd backend
cp .env.example .env # Create from example if available, or use the following template
python setup.py
```
Edit the `.env` file and fill in your credentials:
```bash
NEXT_PUBLIC_URL="http://localhost:3000"
# Supabase credentials from step 1
SUPABASE_URL=your_supabase_url
SUPABASE_ANON_KEY=your_supabase_anon_key
SUPABASE_SERVICE_ROLE_KEY=your_supabase_service_role_key
# Redis credentials from step 2
REDIS_HOST=your_redis_host
REDIS_PORT=6379
REDIS_PASSWORD=your_redis_password
REDIS_SSL=True # Set to False for local Redis without SSL
# Daytona credentials from step 3
DAYTONA_API_KEY=your_daytona_api_key
DAYTONA_SERVER_URL="https://app.daytona.io/api"
DAYTONA_TARGET="us"
# Anthropic
ANTHROPIC_API_KEY=
# OpenAI API:
OPENAI_API_KEY=your_openai_api_key
# Optional but recommended
TAVILY_API_KEY=your_tavily_api_key # For enhanced search capabilities
FIRECRAWL_API_KEY=your_firecrawl_api_key # For web scraping capabilities
RAPID_API_KEY=
```
3. **Set up Supabase database**:
```bash
# Login to Supabase CLI
supabase login
# Link to your project (find your project reference in the Supabase dashboard)
supabase link --project-ref your_project_reference_id
# Push database migrations
supabase db push
```
Then, go to the Supabase web platform again -> choose your project -> Project Settings -> Data API -> And in the "Exposed Schema" add "basejump" if not already there
4. **Configure frontend environment**:
```bash
cd ../frontend
cp .env.example .env.local # Create from example if available, or use the following template
```
Edit the `.env.local` file:
```
NEXT_PUBLIC_SUPABASE_URL=your_supabase_url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key
NEXT_PUBLIC_BACKEND_URL="http://localhost:8000/api" # Use this for local development
NEXT_PUBLIC_URL="http://localhost:3000"
```
Note: If you're using Docker Compose, use the container name instead of localhost:
```
NEXT_PUBLIC_BACKEND_URL="http://backend:8000/api" # Use this when running with Docker Compose
```
5. **Install dependencies**:
```bash
# Install frontend dependencies
cd frontend
npm install
# Install backend dependencies
cd ../backend
pip install -r requirements.txt
```
6. **Start the application**:
In one terminal, start the frontend:
```bash
cd frontend
npm run dev
```
In another terminal, start the backend:
```bash
cd backend
python api.py
```
5-6. **Docker Compose Alternative**:
Before running with Docker Compose, make sure your environment files are properly configured:
- In `backend/.env`, set all the required environment variables as described above
- For Redis configuration, use `REDIS_HOST=redis` instead of localhost
- The Docker Compose setup will automatically set these Redis environment variables:
```
REDIS_HOST=redis
REDIS_PORT=6379
REDIS_PASSWORD=
REDIS_SSL=False
```
- In `frontend/.env.local`, make sure to set `NEXT_PUBLIC_BACKEND_URL="http://backend:8000/api"` to use the container name
Then run:
```bash
export GITHUB_REPOSITORY="your-github-username/repo-name"
docker compose -f docker-compose.ghcr.yaml up
```
If you're building the images locally instead of using pre-built ones:
```bash
docker compose up
```
The Docker Compose setup includes a Redis service that will be used by the backend automatically.
7. **Access Suna**:
- Open your browser and navigate to `http://localhost:3000`
- Sign up for an account using the Supabase authentication
- Start using your self-hosted Suna instance!
The wizard will guide you through all necessary steps to get your Suna instance up and running. For detailed instructions, troubleshooting tips, and advanced configuration options, see the [Self-Hosting Guide](./SELF-HOSTING.md).
## Acknowledgements
@ -274,7 +111,7 @@ The Docker Compose setup includes a Redis service that will be used by the backe
### Technologies
- [Daytona](https://daytona.io/) - Secure agent execution environment
- [Supabase](https://supabase.com/) -
- [Supabase](https://supabase.com/) - Database and authentication
- [Playwright](https://playwright.dev/) - Browser automation
- [OpenAI](https://openai.com/) - LLM provider
- [Anthropic](https://www.anthropic.com/) - LLM provider
@ -282,7 +119,6 @@ The Docker Compose setup includes a Redis service that will be used by the backe
- [Firecrawl](https://firecrawl.dev/) - Web scraping capabilities
- [RapidAPI](https://rapidapi.com/) - API services
## License
Kortix Suna is licensed under the Apache License, Version 2.0. See [LICENSE](./LICENSE) for the full license text.

260
SELF-HOSTING.md Normal file
View File

@ -0,0 +1,260 @@
# Suna Self-Hosting Guide
This guide provides detailed instructions for setting up and hosting your own instance of Suna, an open-source generalist AI agent.
## Table of Contents
- [Overview](#overview)
- [System Requirements](#system-requirements)
- [Prerequisites](#prerequisites)
- [Installation Steps](#installation-steps)
- [Manual Configuration](#manual-configuration)
- [Post-Installation Steps](#post-installation-steps)
- [Troubleshooting](#troubleshooting)
- [Maintenance](#maintenance)
## Overview
Suna consists of four main components:
1. **Backend API** - Python/FastAPI service for REST endpoints, thread management, and LLM integration
2. **Frontend** - Next.js/React application providing the user interface
3. **Agent Docker** - Isolated execution environment for each agent
4. **Supabase Database** - Handles data persistence and authentication
## Prerequisites
Before starting the installation process, you'll need to set up the following:
### 1. Supabase Project
1. Create an account at [Supabase](https://supabase.com/)
2. Create a new project
3. Note down the following information (found in Project Settings → API):
- Project URL (e.g., `https://abcdefg.supabase.co`)
- API keys (anon key and service role key)
### 2. API Keys
Obtain the following API keys:
#### Required
- **LLM Provider** (at least one of the following):
- [Anthropic](https://console.anthropic.com/) - Recommended for best performance
- [OpenAI](https://platform.openai.com/)
- [Groq](https://console.groq.com/)
- [OpenRouter](https://openrouter.ai/)
- [AWS Bedrock](https://aws.amazon.com/bedrock/)
- **Search and Web Scraping**:
- [Tavily](https://tavily.com/) - For enhanced search capabilities
- [Firecrawl](https://firecrawl.dev/) - For web scraping capabilities
- **Agent Execution**:
- [Daytona](https://app.daytona.io/) - For secure agent execution
#### Optional
- **RapidAPI** - For accessing additional API services (optional)
### 3. Required Software
Ensure the following tools are installed on your system:
- **Git**
- **Docker**
- **Python 3.11**
- **Poetry**
- **Node.js & npm**
- **Supabase CLI**
## Installation Steps
### 1. Clone the Repository
```bash
git clone https://github.com/kortix-ai/suna.git
cd suna
```
### 2. Run the Setup Wizard
The setup wizard will guide you through the installation process:
```bash
python setup.py
```
The wizard will:
- Check if all required tools are installed
- Collect your API keys and configuration information
- Set up the Supabase database
- Configure environment files
- Install dependencies
- Start Suna using your preferred method
### 3. Supabase Configuration
During setup, you'll need to:
1. Log in to the Supabase CLI
2. Link your local project to your Supabase project
3. Push database migrations
4. Manually expose the 'basejump' schema in Supabase:
- Go to your Supabase project
- Navigate to Project Settings → API
- Add 'basejump' to the Exposed Schema section
### 4. Daytona Configuration
As part of the setup, you'll need to:
1. Create a Daytona account
2. Generate an API key
3. Create a Docker image:
- Image name: `kortix/suna:0.1`
- Entrypoint: `/usr/bin/supervisord -n -c /etc/supervisor/conf.d/supervisord.conf`
## Manual Configuration
If you prefer to configure your installation manually, or if you need to modify the configuration after installation, here's what you need to know:
### Backend Configuration (.env)
```
# Environment Mode
ENV_MODE=local
# DATABASE
SUPABASE_URL=https://your-project.supabase.co
SUPABASE_ANON_KEY=your-anon-key
SUPABASE_SERVICE_ROLE_KEY=your-service-role-key
# REDIS
REDIS_HOST=redis
REDIS_PORT=6379
REDIS_PASSWORD=
REDIS_SSL=false
# LLM Providers
ANTHROPIC_API_KEY=your-anthropic-key
OPENAI_API_KEY=your-openai-key
MODEL_TO_USE=anthropic/claude-3-7-sonnet-latest
# WEB SEARCH
TAVILY_API_KEY=your-tavily-key
# WEB SCRAPE
FIRECRAWL_API_KEY=your-firecrawl-key
FIRECRAWL_URL=https://api.firecrawl.dev
# Sandbox container provider
DAYTONA_API_KEY=your-daytona-key
DAYTONA_SERVER_URL=https://app.daytona.io/api
DAYTONA_TARGET=us
NEXT_PUBLIC_URL=http://localhost:3000
```
### Frontend Configuration (.env.local)
The frontend configuration is stored in `frontend/.env.local` and includes:
- Supabase connection details
- Backend API URL
Example configuration:
```
NEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=your-anon-key
NEXT_PUBLIC_BACKEND_URL=http://backend:8000/api
NEXT_PUBLIC_URL=http://localhost:3000
```
## Post-Installation Steps
After completing the installation, you'll need to:
1. **Create an account** - Use Supabase authentication to create your first account
2. **Verify installations** - Check that all components are running correctly
## Startup Options
Suna can be started in two ways:
### 1. Using Docker Compose (Recommended)
This method starts all required services in Docker containers:
```bash
# Using pre-built images (faster)
docker compose -f docker-compose.ghcr.yaml up -d
# OR building images locally (customizable)
docker compose up -d
```
### 2. Manual Startup
This method requires you to start each component separately:
1. Start Redis (required for backend):
```bash
cd backend
docker compose up redis -d
```
2. Start the frontend (in one terminal):
```bash
cd frontend
npm run dev
```
3. Start the backend (in another terminal):
```bash
cd backend
poetry run python3.11 api.py
```
## Troubleshooting
### Common Issues
1. **Docker services not starting**
- Check Docker logs: `docker compose logs`
- Ensure Docker is running correctly
- Verify port availability (3000 for frontend, 8000 for backend)
2. **Database connection issues**
- Verify Supabase configuration
- Check if 'basejump' schema is exposed in Supabase
3. **LLM API key issues**
- Verify API keys are correctly entered
- Check for API usage limits or restrictions
4. **Daytona connection issues**
- Verify Daytona API key
- Check if the container image is correctly configured
### Logs
To view logs and diagnose issues:
```bash
# Docker Compose logs
docker compose logs -f
# Frontend logs (manual setup)
cd frontend
npm run dev
# Backend logs (manual setup)
cd backend
poetry run python3.11 api.py
```
---
For further assistance, join the [Suna Discord Community](https://discord.gg/Py6pCBUUPw) or check the [GitHub repository](https://github.com/kortix-ai/suna) for updates and issues.

View File

@ -109,15 +109,15 @@ async def log_requests_middleware(request: Request, call_next):
raise
# Define allowed origins based on environment
allowed_origins = ["https://www.suna.so", "https://suna.so", "https://staging.suna.so", "http://localhost:3000"]
allowed_origins = ["https://www.suna.so", "https://suna.so", "https://staging.suna.so", "http://app.localhost.com:3000"]
# Add staging-specific origins
if config.ENV_MODE == EnvMode.STAGING:
allowed_origins.append("http://localhost:3000")
allowed_origins.append("http://app.localhost.com:3000")
# Add local-specific origins
if config.ENV_MODE == EnvMode.LOCAL:
allowed_origins.append("http://localhost:3000")
allowed_origins.append("http://app.localhost.com:3000")
app.add_middleware(
CORSMiddleware,