Spaces:
Paused
Paused
|
Download README.md from keithproject/mem0: direct link, hf CLI and curl.
- Browser
- Download file 5.28 kB
-
https://huggingface.co/spaces/keithproject/mem0/resolve/main/README.md
- Command line
-
hf download hf://spaces/keithproject/mem0/README.md
-
curl -L -o README.md https://huggingface.co/spaces/keithproject/mem0/resolve/main/README.md
5.28 kB
| title: Mem0 | |
| emoji: π | |
| colorFrom: pink | |
| colorTo: pink | |
| sdk: docker | |
| pinned: false | |
| # mem0 Self-Hosted on HuggingFace Spaces | |
| Single-container deployment of mem0 (API + Dashboard + PostgreSQL) for HuggingFace Spaces, following the patterns from `buzz` (single-container) and `hermes` (supervisord + nginx). | |
| ## Architecture | |
| ``` | |
| βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| β Single Container (Port 7860) β | |
| β βββββββββββββββ βββββββββββββββ βββββββββββββββββββββββ β | |
| β β PostgreSQL β β mem0 API β β mem0 Dashboard β β | |
| β β (5432) β β (8000) β β (3000) β β | |
| β ββββββββ¬βββββββ ββββββββ¬βββββββ ββββββββββββ¬βββββββββββ β | |
| β β β β β | |
| β ββββββββββββββββββΌβββββββββββββββββββββββ β | |
| β βΌ β | |
| β βββββββββββββββ β | |
| β β Nginx β β | |
| β β (7860) β β | |
| β βββββββββββββββ β | |
| β β β | |
| β βββββββ΄ββββββ β | |
| β β Supervisord β | |
| β βββββββββββββ β | |
| βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| ``` | |
| ## Quick Start | |
| ### 1. Clone and Setup | |
| ```bash | |
| cd mem0 | |
| cp .env.example .env | |
| # Edit .env with your values (required: POSTGRES_PASSWORD, OPENAI_API_KEY, JWT_SECRET) | |
| ``` | |
| ### 2. Build and Run | |
| ```bash | |
| docker compose build | |
| docker compose up -d | |
| ``` | |
| ### 3. Access | |
| - **Dashboard**: http://localhost:7860 | |
| - **API Docs**: http://localhost:7860/docs | |
| - **Health Check**: http://localhost:7860/health | |
| ## Required Environment Variables | |
| | Variable | Description | Required | | |
| |----------|-------------|----------| | |
| | `POSTGRES_PASSWORD` | PostgreSQL password (generate: `openssl rand -base64 32`) | Yes | | |
| | `OPENAI_API_KEY` | OpenAI API key for LLM/embeddings | Yes | | |
| | `JWT_SECRET` | JWT signing secret (generate: `openssl rand -base64 48`) | Yes | | |
| | `ADMIN_API_KEY` | Optional admin API key (generate: `openssl rand -base64 32`) | No | | |
| | `AUTH_DISABLED` | Set to `true` for local dev only | No (default: false) | | |
| ## Features | |
| - β **Single container** - All services in one container (like buzz) | |
| - β **HF Spaces compatible** - Singleton guard prevents duplicate runners | |
| - β **UID 1000** - Works with HF FUSE idmapped mounts | |
| - β **Supervisord** - Manages PostgreSQL, API, Dashboard, Nginx | |
| - β **Nginx routing** - Single port 7860 routes to all services | |
| - β **Persistent storage** - PostgreSQL data persisted to `/data` volume | |
| - β **Auth enabled by default** - Secure by default (JWT + API keys) | |
| - β **Health checks** - Built-in health endpoints | |
| ## Nginx Routing | |
| | Path | Proxies To | | |
| |------|------------| | |
| | `/` | Dashboard (Next.js on 3000) | | |
| | `/api/` | mem0 API (FastAPI on 8000) | | |
| | `/docs` | OpenAPI docs | | |
| | `/redoc` | ReDoc docs | | |
| | `/openapi.json` | OpenAPI spec | | |
| | `/health` | Health check (direct) | | |
| ## Data Persistence | |
| - **PostgreSQL**: `/data/pgdata` β cluster lives directly on the HF persistent volume (no sync/backup loop; FUSE-safe boot repair for empty dirs, `.git/` injection, and `pg_tblspc` symlink) | |
| - **Request logs**: `/opt/data/history` (ephemeral; survives restarts only while the container lives) | |
| ## Development | |
| ### View Logs | |
| ```bash | |
| docker compose logs -f mem0 | |
| ``` | |
| ### Access Container | |
| ```bash | |
| docker compose exec mem0 bash | |
| ``` | |
| ### Run Migrations Manually | |
| ```bash | |
| docker compose exec mem0 gosu mem0 alembic upgrade head | |
| ``` | |
| ## HF Spaces Deployment | |
| 1. Create new Space with **Docker** SDK | |
| 2. Push this repository | |
| 3. Set required secrets in Space settings: | |
| - `POSTGRES_PASSWORD` | |
| - `OPENAI_API_KEY` | |
| - `JWT_SECRET` | |
| - `ADMIN_API_KEY` (optional) | |
| 4. Space will auto-deploy on port 7860 | |
| ## Troubleshooting | |
| ### PostgreSQL won't start | |
| Check logs: `docker compose logs mem0 | grep postgresql` | |
| ### Dashboard shows "API connection failed" | |
| Verify `NEXT_PUBLIC_API_URL=http://localhost:7860/api` in environment | |
| ### Auth errors | |
| Ensure `JWT_SECRET` is set and `AUTH_DISABLED=false` (default) | |
| ### Port conflicts | |
| Change port mapping in `docker-compose.yml`: `"7860:7860"` β `"YOUR_PORT:7860"` | |
| ## License | |
| Apache 2.0 - Based on mem0 (https://github.com/mem0ai/mem0) | |