Overview
Ansa can be self-hosted using Docker. This gives you full control over your data and infrastructure.Prerequisites
- Docker and Docker Compose
- An LLM API key (Anthropic or OpenAI)
- A domain with SSL (for production)
Quick Start
1
Clone the repository
2
Create environment file
.env and add your API keys:3
Start services
- API on port 3001
- Dashboard on port 3000
- Widget on port 3002
- PostgreSQL with pgvector
4
Run migrations
Configuration
Environment Variables
| Variable | Required | Description |
|---|---|---|
ANTHROPIC_API_KEY | One of | Anthropic API key for Claude models |
OPENAI_API_KEY | these | OpenAI API key for GPT models |
BETTER_AUTH_SECRET | Yes | Secret for session encryption |
DATABASE_URL | No | Auto-configured for Docker |
API_URL | No | Public API URL (default: http://localhost:3001) |
DASHBOARD_URL | No | Public dashboard URL (default: http://localhost:3000) |
WIDGET_URL | No | Public widget URL (default: http://localhost:3002) |
DOCS_URL | No | Documentation URL |
RESEND_API_KEY | No | For email verification/magic links |
EMAIL_FROM | No | Sender email address |
GOOGLE_CLIENT_ID | No | Google OAuth client ID |
GOOGLE_CLIENT_SECRET | No | Google OAuth client secret |
GITHUB_CLIENT_ID | No | GitHub OAuth client ID |
GITHUB_CLIENT_SECRET | No | GitHub OAuth client secret |
Production Setup
For production deployments:- Use a reverse proxy (nginx, Caddy, Traefik) for SSL termination
- Set proper URLs in your
.env: - Use a managed database for better reliability
- Enable backups for your PostgreSQL data
Example nginx Configuration
Updating
To update to the latest version:Troubleshooting
Database connection errors
Database connection errors
Make sure PostgreSQL is running and healthy:
Widget not loading
Widget not loading
Check that the widget URL is accessible and CORS is configured properly.
The API allows requests from
DASHBOARD_URL and WIDGET_URL.Email not sending
Email not sending
Verify your
RESEND_API_KEY and EMAIL_FROM are set correctly.
Check the API logs for email errors: