Self-Hosting
Deploy Agentsmith on your own infrastructure
Overview
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.
Agentsmith is currently in alpha. Self-hosting documentation and support will be more comprehensive as we move out of the alpha phase. Railway template support is planned for easier deployment. If you encounter any issues, please reach out to support@agentsmith.dev for assistance.
Prerequisites
Before you begin, ensure you have:
- A Supabase account and project
- A GitHub account (for GitHub App setup)
- A deployment platform (Vercel, Railway, Render, or similar)
Deployment Steps
1. Fork the Repository
First, fork the Agentsmith repository to your GitHub account:
- Go to https://github.com/chad-syntax/agentsmith
- Click the "Fork" button in the top-right corner
- Clone your forked repository:
git clone https://github.com/your-username/agentsmith.git cd agentsmith
2. Set Up Supabase
Create a Supabase Project
- Go to supabase.com and create a new project
- Wait for the project to be fully initialized
Get API Keys
- Navigate to Settings > API in your Supabase dashboard
- Copy the Project URL and anon/public key (you'll need these for environment variables)
- Copy the JWT secret (used for the
github_webhook
service role)
Apply Database Schema
The project includes migration files in /supabase/migrations/
. Apply them using the Supabase CLI:
# Install Supabase CLI
npm install -g supabase
# Login to Supabase
supabase login
# Link your project
supabase link --project-ref your-project-ref
# Push migrations
supabase db push
Configure Authentication
- In Supabase Dashboard > Authentication > Settings
- Add your site URL to "Site URL" field
- Add redirect URLs for OAuth (see GitHub App Setup section)
3. Set Up GitHub App
Agentsmith requires a GitHub App for repository synchronization and OAuth authentication.
Create a GitHub App
- Go to GitHub > Settings > Developer settings > GitHub Apps
- Click "New GitHub App"
- Fill in the following:
- GitHub App name: Choose a unique name
- Homepage URL:
https://your-domain.com
- Setup URL:
https://your-domain.com/github/setup
- Webhook URL:
https://your-domain.com/api/github/webhook
- Webhook secret: Generate a secure random string
Set Permissions
Configure the following repository permissions:
- Contents: Read & Write
- Metadata: Read-only
- Pull requests: Read & Write
- Issues: Read & Write
- Account Permissions: Read-only (for email address)
Subscribe to Events
- Push
- Pull request
Generate Private Key
- Scroll down to "Private keys" section
- Click "Generate a private key"
- Download the
.pem
file - Convert to base64:
base64 -i path/to/your-key.pem
- Save this base64 string for your environment variables
Configure OAuth Credentials
- In your GitHub App's settings page, navigate to the OAuth settings
- Generate a new client secret
- Copy the "Client ID" and the newly generated "Client Secret"
- Add these to your Supabase project's GitHub auth provider settings
- Ensure the "Authorization callback URL" points to your Supabase callback URL:
https://your-supabase-project-ref.supabase.co/auth/v1/callback
Create a Service User
- run the
agentsmith_utils.create_user('github_webhook@agentsmith.app', 'some_long_password')
function in the Supabase SQL Editor - Copy the UUID of the new user
- Add this to your environment variables:
GITHUB_WEBHOOK_SERVICE_USER_ID
This user id is used to generate a JWT for the Github Webhook service user instead of using the service role. This helps limit the scope of the service role to only the necessary permissions.
4. Configure Environment Variables
Set up the following environment variables in your deployment platform:
# Supabase Configuration
NEXT_PUBLIC_SUPABASE_URL=your_supabase_project_url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key
SUPABASE_JWT_SECRET=your_supabase_jwt_secret
# GitHub App Configuration
GITHUB_APP_ID=your_github_app_id
GITHUB_APP_PRIVATE_KEY=your_github_app_private_key_base64
GITHUB_APP_WEBHOOK_SECRET=your_github_app_webhook_secret
GITHUB_APP_NAME=your_github_app_name
GITHUB_WEBHOOK_SERVICE_USER_ID=your_github_webhook_service_user_id
# GitHub OAuth (for Supabase Auth)
SUPABASE_AUTH_GITHUB_CLIENT_ID=your_github_oauth_client_id
SUPABASE_AUTH_GITHUB_SECRET=your_github_oauth_client_secret
# Site Configuration
NEXT_PUBLIC_SITE_URL=https://your-domain.com
# Optional: Analytics
NEXT_PUBLIC_POSTHOG_KEY=your_posthog_key
NEXT_PUBLIC_POSTHOG_HOST=your_posthog_host
SENTRY_AUTH_TOKEN=your_sentry_auth_token
# Optional: Cloudflare Turnstile (for anonymous email submission)
NEXT_PUBLIC_CLOUDFLARE_TURNSTILE_SITE_KEY=your_cloudflare_turnstile_site_key
CLOUDFLARE_TURNSTILE_SECRET_KEY=your_cloudflare_turnstile_secret_key
Required Environment Variables
Variable | Description | Where to Get |
---|---|---|
NEXT_PUBLIC_SUPABASE_URL | Your Supabase project URL | Supabase Dashboard > Settings > API |
NEXT_PUBLIC_SUPABASE_ANON_KEY | Supabase anonymous/public key | Supabase Dashboard > Settings > API |
SUPABASE_JWT_SECRET | Supabase JWT secret for signing tokens | Supabase Dashboard > Settings > API > JWT Secret |
GITHUB_APP_ID | GitHub App ID | GitHub > Settings > Developer settings > GitHub Apps |
GITHUB_APP_PRIVATE_KEY | GitHub App private key (base64 encoded) | Generated when creating GitHub App |
GITHUB_APP_WEBHOOK_SECRET | GitHub App webhook secret | Set when creating GitHub App |
GITHUB_APP_NAME | GitHub App name/slug | GitHub App settings |
GITHUB_WEBHOOK_SERVICE_USER_ID | Github Sync Service User UUID | Supabase Auth Dashboard (after creating the svc user) |
SUPABASE_AUTH_GITHUB_CLIENT_ID | GitHub OAuth App Client ID | GitHub App settings |
SUPABASE_AUTH_GITHUB_SECRET | GitHub OAuth App Client Secret | GitHub App settings |
NEXT_PUBLIC_SITE_URL | Your site URL | Your deployment URL |
Optional Environment Variables
Variable | Description | Where to Get |
---|---|---|
NEXT_PUBLIC_POSTHOG_KEY | PostHog key for analytics | PostHog Project Settings |
NEXT_PUBLIC_POSTHOG_HOST | PostHog host for analytics | PostHog Project Settings |
SENTRY_AUTH_TOKEN | Sentry auth token | Sentry Project Settings |
NEXT_PUBLIC_CLOUDFLARE_TURNSTILE_SITE_KEY | Cloudflare Turnstile Site Key | Cloudflare Dashboard > Turnstile |
CLOUDFLARE_TURNSTILE_SECRET_KEY | Cloudflare Turnstile Secret Key | Cloudflare Dashboard > Turnstile |
5. Deploy the Application
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.
Popular deployment options:
- Vercel - Optimized for Next.js applications
- Railway - Simple deployment with database integration
- Render - Full-stack platform with free tier
6. Verify Deployment
After deployment, verify that:
- Your application is accessible at your domain
- Authentication is working properly
- GitHub App integration is functional
- Database migrations have been applied successfully
If you encounter issues with self-hosting, submit an issue on our GitHub repository at https://github.com/chad-syntax/agentsmith/issues or reach out to support at support@agentsmith.dev. We're here to help!