You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
198 lines
5.6 KiB
198 lines
5.6 KiB
services:
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# PostgreSQL with pgvector
|
|
# ---------------------------------------------------------------------------
|
|
postgres:
|
|
image: pgvector/pgvector:pg16
|
|
container_name: second-brain-postgres
|
|
restart: unless-stopped
|
|
environment:
|
|
POSTGRES_DB: second_brain
|
|
POSTGRES_USER: brain
|
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-brain}
|
|
volumes:
|
|
- postgres_data:/var/lib/postgresql/data
|
|
- ./infra/database/schema.sql:/docker-entrypoint-initdb.d/01_schema.sql:ro
|
|
ports:
|
|
- "${POSTGRES_PORT:-5432}:5432"
|
|
networks:
|
|
- brain-net
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U brain -d second_brain"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Redis (job queue)
|
|
# ---------------------------------------------------------------------------
|
|
redis:
|
|
image: redis:7-alpine
|
|
container_name: second-brain-redis
|
|
restart: unless-stopped
|
|
volumes:
|
|
- redis_data:/data
|
|
networks:
|
|
- brain-net
|
|
healthcheck:
|
|
test: ["CMD", "redis-cli", "ping"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Ollama (local LLM inference)
|
|
# ---------------------------------------------------------------------------
|
|
ollama:
|
|
image: ollama/ollama:latest
|
|
container_name: second-brain-ollama
|
|
restart: unless-stopped
|
|
volumes:
|
|
- ollama_data:/root/.ollama
|
|
ports:
|
|
- "${OLLAMA_PORT:-11434}:11434"
|
|
networks:
|
|
- brain-net
|
|
deploy:
|
|
resources:
|
|
reservations:
|
|
devices:
|
|
- driver: nvidia
|
|
count: all
|
|
capabilities: [gpu]
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-f", "http://localhost:11434/api/tags"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 5
|
|
start_period: 60s
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Ollama model bootstrap (pulls required models on first start)
|
|
# ---------------------------------------------------------------------------
|
|
ollama-bootstrap:
|
|
image: ollama/ollama:latest
|
|
container_name: second-brain-ollama-bootstrap
|
|
depends_on:
|
|
ollama:
|
|
condition: service_healthy
|
|
volumes:
|
|
- ollama_data:/root/.ollama
|
|
networks:
|
|
- brain-net
|
|
entrypoint: ["/bin/sh", "-c"]
|
|
command:
|
|
- |
|
|
OLLAMA_HOST=ollama:11434 ollama pull ${EMBEDDING_MODEL:-nomic-embed-text}
|
|
OLLAMA_HOST=ollama:11434 ollama pull ${CHAT_MODEL:-mistral}
|
|
restart: "no"
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# RAG API (FastAPI)
|
|
# ---------------------------------------------------------------------------
|
|
rag-api:
|
|
build:
|
|
context: ./services/rag-api
|
|
dockerfile: Dockerfile
|
|
container_name: second-brain-rag-api
|
|
restart: unless-stopped
|
|
env_file:
|
|
- .env
|
|
environment:
|
|
DATABASE_URL: postgresql://brain:${POSTGRES_PASSWORD:-brain}@postgres:5432/second_brain
|
|
OLLAMA_URL: http://ollama:11434
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
ollama:
|
|
condition: service_healthy
|
|
ports:
|
|
- "${API_PORT:-8000}:8000"
|
|
networks:
|
|
- brain-net
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-f", "http://localhost:8000/api/v1/health"]
|
|
interval: 15s
|
|
timeout: 5s
|
|
retries: 5
|
|
start_period: 30s
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Ingestion Worker
|
|
# ---------------------------------------------------------------------------
|
|
ingestion-worker:
|
|
build:
|
|
context: ./services/ingestion-worker
|
|
dockerfile: Dockerfile
|
|
container_name: second-brain-ingestion
|
|
restart: unless-stopped
|
|
env_file:
|
|
- .env
|
|
environment:
|
|
DATABASE_URL: postgresql://brain:${POSTGRES_PASSWORD:-brain}@postgres:5432/second_brain
|
|
OLLAMA_URL: http://ollama:11434
|
|
VAULT_PATH: /vault
|
|
volumes:
|
|
- ./vault:/vault:ro
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
ollama:
|
|
condition: service_healthy
|
|
networks:
|
|
- brain-net
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# AI Agents
|
|
# ---------------------------------------------------------------------------
|
|
agents:
|
|
build:
|
|
context: ./services/agents
|
|
dockerfile: Dockerfile
|
|
container_name: second-brain-agents
|
|
restart: unless-stopped
|
|
env_file:
|
|
- .env
|
|
environment:
|
|
DATABASE_URL: postgresql://brain:${POSTGRES_PASSWORD:-brain}@postgres:5432/second_brain
|
|
OLLAMA_URL: http://ollama:11434
|
|
VAULT_PATH: /vault
|
|
volumes:
|
|
- ./vault:/vault:ro
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
rag-api:
|
|
condition: service_healthy
|
|
networks:
|
|
- brain-net
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Web UI (Next.js)
|
|
# ---------------------------------------------------------------------------
|
|
web-ui:
|
|
build:
|
|
context: ./services/web-ui
|
|
dockerfile: Dockerfile
|
|
container_name: second-brain-ui
|
|
restart: unless-stopped
|
|
environment:
|
|
NEXT_PUBLIC_API_URL: http://localhost:${API_PORT:-8000}
|
|
depends_on:
|
|
rag-api:
|
|
condition: service_healthy
|
|
ports:
|
|
- "${UI_PORT:-3000}:3000"
|
|
networks:
|
|
- brain-net
|
|
|
|
volumes:
|
|
postgres_data:
|
|
redis_data:
|
|
ollama_data:
|
|
|
|
networks:
|
|
brain-net:
|
|
driver: bridge
|