Self-Hosting Guide

Self-Hosting Guide

Deploy Agentbase on your own infrastructure with full control over your data and configuration.

Quick Install

# Clone the repository
git clone https://github.com/AgentaFlow/agentbase.git
cd agentbase
 
# Run the installer
npx @agentbase/installer install

The installer will walk you through:

  • Database configuration (PostgreSQL, MongoDB, Redis)
  • Admin account setup
  • AI provider API key configuration
  • Environment file generation

Using the CLI

System Requirements Check

npx @agentbase/installer check

This verifies:

  • Node.js >= 20.0.0
  • pnpm >= 9
  • Python >= 3.10
  • Docker and Docker Compose (optional)
  • Git
  • Sufficient RAM (>= 2 GB) and CPU cores (>= 2)

Installation

# Interactive (recommended)
npx @agentbase/installer install
 
# Non-interactive with flags
npx @agentbase/installer install \
  --non-interactive \
  --db-host localhost \
  --db-port 5432 \
  --db-name agentbase \
  --admin-email admin@example.com \
  --admin-password mysecurepassword \
  --port 3000

Status Check

npx @agentbase/installer status

Shows version, running services, and health of all components.

Updates

# Update to latest (with automatic backup)
npx @agentbase/installer update
 
# Update to specific version
npx @agentbase/installer update --version 1.2.0
 
# Skip backup
npx @agentbase/installer update --no-backup

Docker Deployment

Development

docker compose up -d

This starts PostgreSQL, MongoDB, and Redis. The application services run on the host.

Production

docker compose -f docker-compose.prod.yml up -d

This starts all services (including the app) in containers with production settings.

Environment Variables

VariableDescriptionDefault
NODE_ENVEnvironment (development/production)development
APP_PORTCore API port3001
APP_URLCore API public URLhttp://localhost:3001
FRONTEND_URLFrontend URL (used for CORS)http://localhost:3000
PostgreSQL
POSTGRES_HOSTPostgreSQL hostlocalhost
POSTGRES_PORTPostgreSQL port5432
POSTGRES_USERPostgreSQL usernameagentbase
POSTGRES_PASSWORDPostgreSQL password
POSTGRES_DBPostgreSQL database nameagentbase
RUN_MIGRATIONSAuto-run migrations on startupfalse
MongoDB
MONGO_URIMongoDB connection stringmongodb://agentbase:agentbase_dev@localhost:27017/agentbase?authSource=admin
Redis
REDIS_HOSTRedis hostlocalhost
REDIS_PORTRedis port6379
REDIS_PASSWORDRedis password
JWT
JWT_SECRETJWT signing secret— (auto-generated by installer)
JWT_EXPIRATIONJWT access token expiry24h
JWT_REFRESH_SECRETRefresh token signing secret— (auto-generated by installer)
JWT_REFRESH_EXPIRATIONRefresh token expiry7d
AI Providers
OPENAI_API_KEYOpenAI API key
ANTHROPIC_API_KEYAnthropic API key
GEMINI_API_KEYGoogle Gemini API key
HUGGINGFACE_API_KEYHuggingFace Inference API key
DEFAULT_AI_PROVIDERDefault provider when none specifiedopenai
AI_SERVICE_URLInternal URL of the Python AI microservicehttp://localhost:8000
OAuth (optional)
GITHUB_CLIENT_IDGitHub OAuth App client ID
GITHUB_CLIENT_SECRETGitHub OAuth App client secret
GITHUB_CALLBACK_URLGitHub OAuth callback URLhttp://localhost:3001/api/auth/github/callback
GOOGLE_CLIENT_IDGoogle OAuth client ID
GOOGLE_CLIENT_SECRETGoogle OAuth client secret
GOOGLE_CALLBACK_URLGoogle OAuth callback URLhttp://localhost:3001/api/auth/google/callback
Security
ENCRYPTION_KEY64-hex-char AES-256-GCM key for BYOK provider key encryption— (generate: node -e "console.log(require('crypto').randomBytes(32).toString('hex'))")
Stripe (billing)
STRIPE_SECRET_KEYStripe secret key (sk_live_... / sk_test_...)
STRIPE_WEBHOOK_SECRETStripe webhook signing secret
STRIPE_PUBLISHABLE_KEYStripe publishable key
STRIPE_METERED_PRICE_IDStripe metered price ID for token overage billing
Email (optional)
SMTP_HOSTSMTP server host
SMTP_PORTSMTP port587
SMTP_USERSMTP username
SMTP_PASSWORDSMTP password
EMAIL_FROMDefault from addressnoreply@agentbase.dev
File Uploads (S3)
S3_BUCKETS3 bucket name
S3_REGIONS3 regionus-east-1
S3_ACCESS_KEYS3 access key ID
S3_SECRET_KEYS3 secret access key
S3_ENDPOINTCustom S3-compatible endpoint (e.g. MinIO)
Custom Domains
PLATFORM_DOMAINApex domain for custom domain routingcustom.agentbase.dev
Misc
ENABLE_SWAGGEREnable Swagger UI in productionfalse

SSL/TLS Setup

For production deployments, use the included Nginx configuration:

# Run the SSL setup script
bash deploy/scripts/ssl-setup.sh your-domain.com

This configures Let's Encrypt certificates via certbot.

Backup & Restore

# Create a backup
bash deploy/scripts/backup.sh
 
# Backups include:
# - PostgreSQL database dump
# - MongoDB database dump
# - .env configuration
# - Uploaded files