Skip to content

Commit 36da6e2

Browse files
authored
Merge pull request #77 from redis/fix/better-representation-of-container-images
Document Docker image locations and default to development mode
2 parents bf23a3b + 455fa29 commit 36da6e2

File tree

4 files changed

+114
-40
lines changed

4 files changed

+114
-40
lines changed

Dockerfile

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim
22

3+
# OCI labels for Docker Hub and container registries
4+
LABEL org.opencontainers.image.title="Redis Agent Memory Server"
5+
LABEL org.opencontainers.image.description="A memory layer for AI agents using Redis as the vector database. Provides REST API and MCP server interfaces with semantic search, topic extraction, and conversation summarization."
6+
LABEL org.opencontainers.image.url="https://github.com/redis/agent-memory-server"
7+
LABEL org.opencontainers.image.source="https://github.com/redis/agent-memory-server"
8+
LABEL org.opencontainers.image.documentation="https://redis.github.io/agent-memory-server/"
9+
LABEL org.opencontainers.image.vendor="Redis"
10+
LABEL org.opencontainers.image.licenses="Apache-2.0"
311

412
WORKDIR /app
513

@@ -24,16 +32,30 @@ ADD . /app
2432
RUN --mount=type=cache,target=/root/.cache/uv \
2533
uv sync --frozen --no-dev
2634

35+
# Create non-root user for security
36+
RUN groupadd -r agentmemory && useradd -r -g agentmemory agentmemory && \
37+
chown -R agentmemory:agentmemory /app
38+
2739
ENV PATH="/app/.venv/bin:$PATH"
2840

41+
# Switch to non-root user
42+
USER agentmemory
43+
2944
ENTRYPOINT []
3045

3146
EXPOSE 8000
3247

3348
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
3449
CMD curl -f http://localhost:8000/v1/health || exit 1
3550

36-
# Disable auth by default. Can be overridden with environment variable.
51+
# Disable auth by default for easier local development.
52+
# Override with DISABLE_AUTH=false in production.
3753
ENV DISABLE_AUTH=true
3854

39-
CMD ["agent-memory", "api", "--host", "0.0.0.0", "--port", "8000"]
55+
# Default to development mode (no separate worker needed).
56+
# For production, override the command to remove --no-worker and run a separate task-worker container.
57+
# Examples:
58+
# Development: docker run -p 8000:8000 redislabs/agent-memory-server
59+
# Production API: docker run -p 8000:8000 redislabs/agent-memory-server agent-memory api --host 0.0.0.0 --port 8000
60+
# Production Worker: docker run redislabs/agent-memory-server agent-memory task-worker --concurrency 10
61+
CMD ["agent-memory", "api", "--host", "0.0.0.0", "--port", "8000", "--no-worker"]

README.md

Lines changed: 50 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,56 @@ A memory layer for AI agents using Redis as the vector database.
1616

1717
### 1. Installation
1818

19+
#### Using Docker
20+
21+
Pre-built Docker images are available from:
22+
- **Docker Hub**: [redislabs/agent-memory-server](https://hub.docker.com/r/redislabs/agent-memory-server)
23+
- **GitHub Packages**: [ghcr.io/redis/agent-memory-server](https://github.com/redis/agent-memory-server/pkgs/container/agent-memory-server)
24+
25+
**Quick Start (Development Mode)**:
26+
```bash
27+
# Start with docker-compose (includes Redis, API, MCP, and worker)
28+
docker-compose up
29+
30+
# Or run just the API server (requires separate Redis)
31+
docker run -p 8000:8000 \
32+
-e REDIS_URL=redis://your-redis:6379 \
33+
-e OPENAI_API_KEY=your-key \
34+
redislabs/agent-memory-server:latest
35+
```
36+
37+
The default image runs in development mode (`--no-worker`), which is perfect for testing and development.
38+
39+
**Production Deployment**:
40+
41+
For production, run separate containers for the API and background workers:
42+
43+
```bash
44+
# API Server (without background worker)
45+
docker run -p 8000:8000 \
46+
-e REDIS_URL=redis://your-redis:6379 \
47+
-e OPENAI_API_KEY=your-key \
48+
-e DISABLE_AUTH=false \
49+
redislabs/agent-memory-server:latest \
50+
agent-memory api --host 0.0.0.0 --port 8000
51+
52+
# Background Worker (separate container)
53+
docker run \
54+
-e REDIS_URL=redis://your-redis:6379 \
55+
-e OPENAI_API_KEY=your-key \
56+
redislabs/agent-memory-server:latest \
57+
agent-memory task-worker --concurrency 10
58+
59+
# MCP Server (if needed)
60+
docker run -p 9000:9000 \
61+
-e REDIS_URL=redis://your-redis:6379 \
62+
-e OPENAI_API_KEY=your-key \
63+
redislabs/agent-memory-server:latest \
64+
agent-memory mcp --mode sse --port 9000
65+
```
66+
67+
#### From Source
68+
1969
```bash
2070
# Install dependencies
2171
pip install uv
@@ -159,33 +209,6 @@ uv run ruff check
159209
# Start development stack
160210
docker-compose up
161211
```
162-
163-
## Production Deployment
164-
165-
For production environments, use Docket workers for better reliability and scale:
166-
167-
```bash
168-
# Start the API server (production mode)
169-
uv run agent-memory api
170-
171-
# Start MCP server (production mode - SSE)
172-
uv run agent-memory mcp --mode sse --port 9000
173-
174-
# Start background workers (required for production)
175-
uv run agent-memory task-worker --concurrency 10
176-
```
177-
178-
**Production features:**
179-
- **Authentication**: OAuth2/JWT with multiple providers (Auth0, AWS Cognito, etc.)
180-
- **Redis**: Requires Redis 8 or Redis with RediSearch module (RedisStack recommended)
181-
- **Background Processing**: Docket workers handle memory indexing, summarization, and compaction
182-
- **Scaling**: Supports Redis clustering and horizontal worker scaling
183-
- **Monitoring**: Structured logging and health checks included
184-
185-
**Development vs Production:**
186-
- **Development**: Use `--no-worker` flags for quick setup, tasks run inline
187-
- **Production**: Use separate worker processes for better performance and reliability
188-
189212
## License
190213

191214
Apache License 2.0 - see [LICENSE](LICENSE) file for details.

agent_memory_server/models.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from enum import Enum
55
from typing import Any, Literal
66

7+
from agent_memory_client.models import ClientMemoryRecord
78
from mcp.server.fastmcp.prompts import base
89
from mcp.types import AudioContent, EmbeddedResource, ImageContent, TextContent
910
from pydantic import BaseModel, Field
@@ -209,15 +210,6 @@ class ExtractedMemoryRecord(MemoryRecord):
209210
)
210211

211212

212-
class ClientMemoryRecord(MemoryRecord):
213-
"""A memory record with a client-provided ID"""
214-
215-
id: str = Field(
216-
default_factory=lambda: str(ULID()),
217-
description="Client-provided ID for deduplication and overwrites",
218-
)
219-
220-
221213
class WorkingMemory(BaseModel):
222214
"""Working memory for a session - contains both messages and structured memory records"""
223215

docker-compose.yml

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
services:
2+
# This API service uses --no-worker to run without a worker. When it starts
3+
# background tasks, they run immediately in the API process.
24
api:
35
build:
46
context: .
@@ -26,6 +28,41 @@ services:
2628
interval: 30s
2729
timeout: 10s
2830
retries: 3
31+
# Uses default CMD from Dockerfile (--no-worker for development)
32+
33+
# For testing a production-like setup, you can run this API and the
34+
# task-worker container. This API container does NOT use --no-worker, so when
35+
# it starts background work, the task-worker will process those tasks.
36+
api-for-task-worker:
37+
build:
38+
context: .
39+
dockerfile: Dockerfile
40+
ports:
41+
- "8000:8000"
42+
environment:
43+
- REDIS_URL=redis://redis:6379
44+
- PORT=8000
45+
# Add your API keys here or use a .env file
46+
- OPENAI_API_KEY=${OPENAI_API_KEY}
47+
- ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY}
48+
# Optional configurations with defaults
49+
- LONG_TERM_MEMORY=True
50+
- GENERATION_MODEL=gpt-4o-mini
51+
- EMBEDDING_MODEL=text-embedding-3-small
52+
- ENABLE_TOPIC_EXTRACTION=True
53+
- ENABLE_NER=True
54+
depends_on:
55+
- redis
56+
volumes:
57+
- ./agent_memory_server:/app/agent_memory_server
58+
healthcheck:
59+
test: [ "CMD", "curl", "-f", "http://localhost:8000/v1/health" ]
60+
interval: 30s
61+
timeout: 10s
62+
retries: 3
63+
command: ["agent-memory", "api", "--host", "0.0.0.0", "--port", "8000"]
64+
65+
2966

3067
mcp:
3168
build:
@@ -41,7 +78,7 @@ services:
4178
- "9050:9000"
4279
depends_on:
4380
- redis
44-
command: ["uv", "run", "agent-memory", "mcp", "--mode", "sse"]
81+
command: ["agent-memory", "mcp", "--mode", "sse"]
4582

4683
task-worker:
4784
build:
@@ -55,7 +92,7 @@ services:
5592
# Optional configurations with defaults
5693
depends_on:
5794
- redis
58-
command: ["uv", "run", "agent-memory", "task-worker"]
95+
command: ["agent-memory", "task-worker"]
5996
volumes:
6097
- ./agent_memory_server:/app/agent_memory_server
6198
restart: unless-stopped

0 commit comments

Comments
 (0)