Add authenticated Mem0 memory service #5

Merged
slh merged 2 commits from feat/infra-mem0 into main 2026-07-17 13:50:01 +08:00
4 changed files with 75 additions and 0 deletions
Showing only changes of commit 33e7440342 - Show all commits

2
.gitignore vendored
View File

@ -17,3 +17,5 @@ litellm/.infra-litellm-state
git-bridge/state/
litellm/.env
mem0/.env
mem0/history/

View File

@ -147,6 +147,39 @@ services:
networks:
- git_forge
mem0:
container_name: mem0
build:
context: ./mem0
dockerfile: Dockerfile
args:
MEM0_SOURCE_REF: 42cf18c4e6adb448e981aa1c7b55c1602b0cb670
MEM0AI_VERSION: 2.0.12
HTTP_PROXY: ${MEM0_BUILD_PROXY:-http://192.168.0.4:7890}
HTTPS_PROXY: ${MEM0_BUILD_PROXY:-http://192.168.0.4:7890}
NO_PROXY: localhost,127.0.0.1,postgres,litellm
restart: unless-stopped
stop_grace_period: 30s
env_file:
- ./mem0/.env
depends_on:
postgres:
condition: service_healthy
extra_hosts:
- host.docker.internal:host-gateway
volumes:
- ./mem0/history:/app/history
ports:
- "127.0.0.1:8888:8000"
healthcheck:
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8000/openapi.json', timeout=3).read()"]
interval: 10s
timeout: 5s
retries: 18
start_period: 30s
networks:
- git_forge
networks:
git_forge:
name: git_forge

27
mem0/Dockerfile Normal file
View File

@ -0,0 +1,27 @@
FROM python:3.12-slim-bookworm AS source
ARG MEM0_SOURCE_REF=42cf18c4e6adb448e981aa1c7b55c1602b0cb670
RUN apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates git \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /src
RUN git init \
&& git remote add origin https://github.com/mem0ai/mem0.git \
&& git fetch --depth 1 origin "${MEM0_SOURCE_REF}" \
&& test "$(git rev-parse FETCH_HEAD)" = "${MEM0_SOURCE_REF}" \
&& git checkout --detach FETCH_HEAD
FROM python:3.12-slim-bookworm
ARG MEM0AI_VERSION=2.0.12
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1
WORKDIR /app
COPY --from=source /src/server/requirements.txt /tmp/requirements.txt
RUN sed -i -E "s/^mem0ai.*/mem0ai==${MEM0AI_VERSION}/" /tmp/requirements.txt \
&& pip install --no-cache-dir -r /tmp/requirements.txt \
&& rm -f /tmp/requirements.txt
COPY --from=source /src/server/ /app/
RUN mkdir -p /app/history
EXPOSE 8000
CMD ["sh", "-c", "alembic upgrade head && exec uvicorn main:app --host 0.0.0.0 --port 8000"]

13
mem0/README.md Normal file
View File

@ -0,0 +1,13 @@
# Mem0
Infra runs the authenticated Mem0 OSS REST API without the optional dashboard,
Neo4j, or Qdrant. PostgreSQL/pgvector stores data in isolated `mem0` and
`mem0_app` databases. Model traffic goes through the existing LiteLLM gateway:
- memory extraction: `grok-fast`
- embeddings: `voyage-4`, 1024 dimensions
The service is bound to `127.0.0.1:8888`. The OSS API paths do not use `/v1`.
Runtime secrets live in ignored `mem0/.env` with mode `0600`; no model-provider
credential is copied into Mem0. The image source is pinned to the upstream Mem0
`v2.0.12` release commit.