Docker Installation
Setting up SurfSense using Docker
Known Limitations
⚠️ Important Note: Currently, the following features have limited functionality when running in Docker:
- Ollama integration: Local Ollama models do not work when running SurfSense in Docker. Please use other LLM providers like OpenAI or Gemini instead.
- Web crawler functionality: The web crawler feature currently doesn't work properly within the Docker environment.
We're actively working to resolve these limitations in future releases.
Docker Installation
This guide explains how to run SurfSense using Docker Compose, which is the preferred and recommended method for deployment.
Prerequisites
Before you begin, ensure you have:
- Docker and Docker Compose installed on your machine
- Git (to clone the repository)
- Completed all the prerequisite setup steps including:
- PGVector setup
- Google OAuth configuration
- Unstructured.io API key
- Other required API keys
Installation Steps
-
Configure Environment Variables Set up the necessary environment variables:
Linux/macOS:
Windows (Command Prompt):
Windows (PowerShell):
Edit all
.env
files and fill in the required values:
Docker-Specific Environment Variables
ENV VARIABLE | DESCRIPTION | DEFAULT VALUE |
---|---|---|
FRONTEND_PORT | Port for the frontend service | 3000 |
BACKEND_PORT | Port for the backend API service | 8000 |
POSTGRES_PORT | Port for the PostgreSQL database | 5432 |
PGADMIN_PORT | Port for pgAdmin web interface | 5050 |
POSTGRES_USER | PostgreSQL username | postgres |
POSTGRES_PASSWORD | PostgreSQL password | postgres |
POSTGRES_DB | PostgreSQL database name | surfsense |
PGADMIN_DEFAULT_EMAIL | Email for pgAdmin login | admin@surfsense.com |
PGADMIN_DEFAULT_PASSWORD | Password for pgAdmin login | surfsense |
NEXT_PUBLIC_API_URL | URL of the backend API (used by frontend) | http://backend:8000 |
Backend Environment Variables:
ENV VARIABLE | DESCRIPTION |
---|---|
DATABASE_URL | PostgreSQL connection string (e.g., postgresql+asyncpg://postgres:postgres@localhost:5432/surfsense ) |
SECRET_KEY | JWT Secret key for authentication (should be a secure random string) |
GOOGLE_OAUTH_CLIENT_ID | Google OAuth client ID obtained from Google Cloud Console |
GOOGLE_OAUTH_CLIENT_SECRET | Google OAuth client secret obtained from Google Cloud Console |
NEXT_FRONTEND_URL | URL where your frontend application is hosted (e.g., http://localhost:3000 ) |
EMBEDDING_MODEL | Name of the embedding model (e.g., openai://text-embedding-ada-002 , anthropic://claude-v1 , mixedbread-ai/mxbai-embed-large-v1 ) |
RERANKERS_MODEL_NAME | Name of the reranker model (e.g., ms-marco-MiniLM-L-12-v2 ) |
RERANKERS_MODEL_TYPE | Type of reranker model (e.g., flashrank ) |
FAST_LLM | LiteLLM routed smaller, faster LLM (e.g., openai/gpt-4o-mini , ollama/deepseek-r1:8b ) |
STRATEGIC_LLM | LiteLLM routed advanced LLM for complex tasks (e.g., openai/gpt-4o , ollama/gemma3:12b ) |
LONG_CONTEXT_LLM | LiteLLM routed LLM for longer context windows (e.g., gemini/gemini-2.0-flash , ollama/deepseek-r1:8b ) |
UNSTRUCTURED_API_KEY | API key for Unstructured.io service for document parsing |
FIRECRAWL_API_KEY | API key for Firecrawl service for web crawling |
TTS_SERVICE | Text-to-Speech API provider for Podcasts (e.g., openai/tts-1 , azure/neural , vertex_ai/ ). See supported providers |
STT_SERVICE | Speech-to-Text API provider for Podcasts (e.g., openai/whisper-1 ). See supported providers |
Include API keys for the LLM providers you're using. For example:
OPENAI_API_KEY
: If using OpenAI modelsGEMINI_API_KEY
: If using Google Gemini models
Optional Backend LangSmith Observability:
ENV VARIABLE | DESCRIPTION |
---|---|
LANGSMITH_TRACING | Enable LangSmith tracing (e.g., true ) |
LANGSMITH_ENDPOINT | LangSmith API endpoint (e.g., https://api.smith.langchain.com ) |
LANGSMITH_API_KEY | Your LangSmith API key |
LANGSMITH_PROJECT | LangSmith project name (e.g., surfsense ) |
Optional Backend LiteLLM API Base URLs:
ENV VARIABLE | DESCRIPTION |
---|---|
FAST_LLM_API_BASE | Custom API base URL for the fast LLM |
STRATEGIC_LLM_API_BASE | Custom API base URL for the strategic LLM |
LONG_CONTEXT_LLM_API_BASE | Custom API base URL for the long context LLM |
TTS_SERVICE_API_BASE | Custom API base URL for the Text-to-Speech (TTS) service |
STT_SERVICE_API_BASE | Custom API base URL for the Speech-to-Text (STT) service |
For other LLM providers, refer to the LiteLLM documentation.
Frontend Environment Variables
ENV VARIABLE | DESCRIPTION |
---|---|
NEXT_PUBLIC_FASTAPI_BACKEND_URL | URL of the backend service (e.g., http://localhost:8000 ) |
-
Build and Start Containers
Start the Docker containers:
Linux/macOS/Windows:
To run in detached mode (in the background):
Linux/macOS/Windows:
Note for Windows users: If you're using older Docker Desktop versions, you might need to use
docker compose
(with a space) instead ofdocker compose
. -
Access the Applications
Once the containers are running, you can access:
- Frontend: http://localhost:3000
- Backend API: http://localhost:8000
- API Documentation: http://localhost:8000/docs
- pgAdmin: http://localhost:5050
Using pgAdmin
pgAdmin is included in the Docker setup to help manage your PostgreSQL database. To connect:
- Open pgAdmin at http://localhost:5050
- Login with the credentials from your
.env
file (default: admin@surfsense.com / surfsense) - Right-click "Servers" > "Create" > "Server"
- In the "General" tab, name your connection (e.g., "SurfSense DB")
- In the "Connection" tab:
- Host:
db
- Port:
5432
- Maintenance database:
surfsense
- Username:
postgres
(or your custom POSTGRES_USER) - Password:
postgres
(or your custom POSTGRES_PASSWORD)
- Host:
- Click "Save" to connect
Useful Docker Commands
Container Management
-
Stop containers:
Linux/macOS/Windows:
-
View logs:
Linux/macOS/Windows:
-
Restart a specific service:
Linux/macOS/Windows:
-
Execute commands in a running container:
Linux/macOS/Windows:
Troubleshooting
- Linux/macOS: If you encounter permission errors, you may need to run the docker commands with
sudo
. - Windows: If you see access denied errors, make sure you're running Command Prompt or PowerShell as Administrator.
- If ports are already in use, modify the port mappings in the
docker-compose.yml
file. - For backend dependency issues, check the
Dockerfile
in the backend directory. - For frontend dependency issues, check the
Dockerfile
in the frontend directory. - Windows-specific: If you encounter line ending issues (CRLF vs LF), configure Git to handle line endings properly with
git config --global core.autocrlf true
before cloning the repository.
Next Steps
Once your installation is complete, you can start using SurfSense! Navigate to the frontend URL and log in using your Google account.