|
| 1 | +--- |
| 2 | +title: Self-Hosting |
| 3 | +description: Deploy Agentsmith on your own infrastructure |
| 4 | +--- |
| 5 | + |
| 6 | +import { Alert, AlertTitle, AlertDescription } from '@/components/ui/alert'; |
| 7 | +import { TriangleAlert, Info } from 'lucide-react'; |
| 8 | + |
| 9 | +## Overview |
| 10 | + |
| 11 | +Agentsmith can be self-hosted on your own infrastructure, giving you complete control over your AI agent development platform. This guide will walk you through the process of deploying Agentsmith using Next.js and Supabase. |
| 12 | + |
| 13 | +<Alert variant="warning"> |
| 14 | + <TriangleAlert /> |
| 15 | + <AlertTitle>Alpha Status</AlertTitle> |
| 16 | + <AlertDescription> |
| 17 | + Agentsmith is currently in alpha. Self-hosting documentation and support will be more |
| 18 | + comprehensive as we move out of the alpha phase. Railway template support is planned for easier |
| 19 | + deployment. If you encounter any issues, please reach out to support@agentsmith.app for |
| 20 | + assistance. |
| 21 | + </AlertDescription> |
| 22 | +</Alert> |
| 23 | + |
| 24 | +## Prerequisites |
| 25 | + |
| 26 | +Before you begin, ensure you have: |
| 27 | + |
| 28 | +- A Supabase account and project |
| 29 | +- A GitHub account (for GitHub App setup) |
| 30 | +- A deployment platform (Vercel, Railway, Render, or similar) |
| 31 | +- Node.js 22+ and npm (for local development) |
| 32 | +- Docker (for local development) |
| 33 | + |
| 34 | +## Deployment Steps |
| 35 | + |
| 36 | +### 1. Fork the Repository |
| 37 | + |
| 38 | +First, fork the Agentsmith repository to your GitHub account: |
| 39 | + |
| 40 | +1. Go to [https://github.com/chad-syntax/agentsmith](https://github.com/chad-syntax/agentsmith) |
| 41 | +2. Click the "Fork" button in the top-right corner |
| 42 | +3. Clone your forked repository: |
| 43 | + ```bash |
| 44 | + git clone https://github.com/your-username/agentsmith.git |
| 45 | + cd agentsmith |
| 46 | + ``` |
| 47 | + |
| 48 | +### 2. Set Up Supabase |
| 49 | + |
| 50 | +#### Create a Supabase Project |
| 51 | + |
| 52 | +1. Go to [supabase.com](https://supabase.com) and create a new project |
| 53 | +2. Wait for the project to be fully initialized |
| 54 | + |
| 55 | +#### Get API Keys |
| 56 | + |
| 57 | +1. Navigate to Settings > API in your Supabase dashboard |
| 58 | +2. Copy the Project URL and anon/public key (you'll need these for environment variables) |
| 59 | +3. Copy the JWT secret (used for the `github_webhook` service role) |
| 60 | + |
| 61 | +#### Apply Database Schema |
| 62 | + |
| 63 | +The project includes migration files in `/supabase/migrations/`. Apply them using the Supabase CLI: |
| 64 | + |
| 65 | +```bash |
| 66 | +# Install Supabase CLI |
| 67 | +npm install -g supabase |
| 68 | + |
| 69 | +# Login to Supabase |
| 70 | +supabase login |
| 71 | + |
| 72 | +# Link your project |
| 73 | +supabase link --project-ref your-project-ref |
| 74 | + |
| 75 | +# Push migrations |
| 76 | +supabase db push |
| 77 | +``` |
| 78 | + |
| 79 | +#### Configure Authentication |
| 80 | + |
| 81 | +1. In Supabase Dashboard > Authentication > Settings |
| 82 | +2. Add your site URL to "Site URL" field |
| 83 | +3. Add redirect URLs for OAuth (see GitHub App Setup section) |
| 84 | + |
| 85 | +### 3. Set Up GitHub App |
| 86 | + |
| 87 | +Agentsmith requires a GitHub App for repository synchronization and OAuth authentication. |
| 88 | + |
| 89 | +#### Create a GitHub App |
| 90 | + |
| 91 | +1. Go to GitHub > Settings > Developer settings > GitHub Apps |
| 92 | +2. Click "New GitHub App" |
| 93 | +3. Fill in the following: |
| 94 | + - **GitHub App name**: Choose a unique name |
| 95 | + - **Homepage URL**: `https://your-domain.com` |
| 96 | + - **Setup URL**: `https://your-domain.com/github/setup` |
| 97 | + - **Webhook URL**: `https://your-domain.com/api/github/webhook` |
| 98 | + - **Webhook secret**: Generate a secure random string |
| 99 | + |
| 100 | +#### Set Permissions |
| 101 | + |
| 102 | +Configure the following repository permissions: |
| 103 | + |
| 104 | +- **Contents**: Read & Write |
| 105 | +- **Metadata**: Read-only |
| 106 | +- **Pull requests**: Read & Write |
| 107 | +- **Issues**: Read & Write |
| 108 | +- **Account Permissions**: Read-only (for email address) |
| 109 | + |
| 110 | +#### Subscribe to Events |
| 111 | + |
| 112 | +- Push |
| 113 | +- Pull request |
| 114 | + |
| 115 | +#### Generate Private Key |
| 116 | + |
| 117 | +1. Scroll down to "Private keys" section |
| 118 | +2. Click "Generate a private key" |
| 119 | +3. Download the `.pem` file |
| 120 | +4. Convert to base64: `base64 -i path/to/your-key.pem` |
| 121 | +5. Save this base64 string for your environment variables |
| 122 | + |
| 123 | +#### Configure OAuth Credentials |
| 124 | + |
| 125 | +1. In your GitHub App's settings page, navigate to the OAuth settings |
| 126 | +2. Generate a new client secret |
| 127 | +3. Copy the "Client ID" and the newly generated "Client Secret" |
| 128 | +4. Add these to your Supabase project's GitHub auth provider settings |
| 129 | +5. Ensure the "Authorization callback URL" points to your Supabase callback URL: `https://your-supabase-project-ref.supabase.co/auth/v1/callback` |
| 130 | + |
| 131 | +### 4. Configure Environment Variables |
| 132 | + |
| 133 | +Set up the following environment variables in your deployment platform: |
| 134 | + |
| 135 | +```bash |
| 136 | +# Supabase Configuration |
| 137 | +NEXT_PUBLIC_SUPABASE_URL=your_supabase_project_url |
| 138 | +NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key |
| 139 | +SUPABASE_JWT_SECRET=your_supabase_jwt_secret |
| 140 | + |
| 141 | +# GitHub App Configuration |
| 142 | +GITHUB_APP_ID=your_github_app_id |
| 143 | +GITHUB_APP_PRIVATE_KEY=your_github_app_private_key_base64 |
| 144 | +GITHUB_APP_WEBHOOK_SECRET=your_github_app_webhook_secret |
| 145 | +GITHUB_APP_NAME=your_github_app_name |
| 146 | + |
| 147 | +# GitHub OAuth (for Supabase Auth) |
| 148 | +SUPABASE_AUTH_GITHUB_CLIENT_ID=your_github_oauth_client_id |
| 149 | +SUPABASE_AUTH_GITHUB_SECRET=your_github_oauth_client_secret |
| 150 | + |
| 151 | +# Site Configuration |
| 152 | +NEXT_PUBLIC_SITE_URL=https://your-domain.com |
| 153 | + |
| 154 | +# Optional: Analytics |
| 155 | +NEXT_PUBLIC_POSTHOG_KEY=your_posthog_key |
| 156 | +NEXT_PUBLIC_POSTHOG_HOST=your_posthog_host |
| 157 | + |
| 158 | +# Optional: Cloudflare Turnstile (for anonymous email submission) |
| 159 | +NEXT_PUBLIC_CLOUDFLARE_TURNSTILE_SITE_KEY=your_cloudflare_turnstile_site_key |
| 160 | +CLOUDFLARE_TURNSTILE_SECRET_KEY=your_cloudflare_turnstile_secret_key |
| 161 | +``` |
| 162 | + |
| 163 | +#### Required Environment Variables |
| 164 | + |
| 165 | +| Variable | Description | Where to Get | |
| 166 | +| -------------------------------- | --------------------------------------- | ---------------------------------------------------- | |
| 167 | +| `NEXT_PUBLIC_SUPABASE_URL` | Your Supabase project URL | Supabase Dashboard > Settings > API | |
| 168 | +| `NEXT_PUBLIC_SUPABASE_ANON_KEY` | Supabase anonymous/public key | Supabase Dashboard > Settings > API | |
| 169 | +| `SUPABASE_JWT_SECRET` | Supabase JWT secret for signing tokens | Supabase Dashboard > Settings > API > JWT Secret | |
| 170 | +| `GITHUB_APP_ID` | GitHub App ID | GitHub > Settings > Developer settings > GitHub Apps | |
| 171 | +| `GITHUB_APP_PRIVATE_KEY` | GitHub App private key (base64 encoded) | Generated when creating GitHub App | |
| 172 | +| `GITHUB_APP_WEBHOOK_SECRET` | GitHub App webhook secret | Set when creating GitHub App | |
| 173 | +| `GITHUB_APP_NAME` | GitHub App name/slug | GitHub App settings | |
| 174 | +| `SUPABASE_AUTH_GITHUB_CLIENT_ID` | GitHub OAuth App Client ID | GitHub App settings | |
| 175 | +| `SUPABASE_AUTH_GITHUB_SECRET` | GitHub OAuth App Client Secret | GitHub App settings | |
| 176 | +| `NEXT_PUBLIC_SITE_URL` | Your site URL | Your deployment URL | |
| 177 | + |
| 178 | +#### Optional Environment Variables |
| 179 | + |
| 180 | +| Variable | Description | Where to Get | |
| 181 | +| ------------------------------------------- | ------------------------------- | -------------------------------- | |
| 182 | +| `NEXT_PUBLIC_POSTHOG_KEY` | PostHog key for analytics | PostHog Project Settings | |
| 183 | +| `NEXT_PUBLIC_POSTHOG_HOST` | PostHog host for analytics | PostHog Project Settings | |
| 184 | +| `NEXT_PUBLIC_CLOUDFLARE_TURNSTILE_SITE_KEY` | Cloudflare Turnstile Site Key | Cloudflare Dashboard > Turnstile | |
| 185 | +| `CLOUDFLARE_TURNSTILE_SECRET_KEY` | Cloudflare Turnstile Secret Key | Cloudflare Dashboard > Turnstile | |
| 186 | + |
| 187 | +### 5. Deploy the Application |
| 188 | + |
| 189 | +Connect your forked repository to your preferred deployment platform and configure the environment variables listed above. The application is a standard Next.js app and can be deployed to any platform that supports Node.js applications. |
| 190 | + |
| 191 | +**Popular deployment options:** |
| 192 | + |
| 193 | +- [Vercel](https://vercel.com) - Optimized for Next.js applications |
| 194 | +- [Railway](https://railway.app) - Simple deployment with database integration |
| 195 | +- [Render](https://render.com) - Full-stack platform with free tier |
| 196 | + |
| 197 | +### 6. Verify Deployment |
| 198 | + |
| 199 | +After deployment, verify that: |
| 200 | + |
| 201 | +1. Your application is accessible at your domain |
| 202 | +2. Authentication is working properly |
| 203 | +3. GitHub App integration is functional |
| 204 | +4. Database migrations have been applied successfully |
| 205 | + |
| 206 | +<Alert variant="default"> |
| 207 | + <Info /> |
| 208 | + <AlertTitle>Need Support?</AlertTitle> |
| 209 | + <AlertDescription> |
| 210 | + If you encounter issues with self-hosting, please reach out to our support team at{' '} |
| 211 | + <a href="mailto:support@agentsmith.app" className="underline"> |
| 212 | + support@agentsmith.app |
| 213 | + </a> |
| 214 | + . We're here to help! |
| 215 | + </AlertDescription> |
| 216 | +</Alert> |
0 commit comments