-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathDockerfile
More file actions
153 lines (116 loc) · 5.54 KB
/
Dockerfile
File metadata and controls
153 lines (116 loc) · 5.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# ============================================
# BUILDER BASE - Build tools for compilation
# ============================================
FROM python:3.12-slim-bookworm AS builder-base
WORKDIR /app
# Copy uv binary from official image
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
ENV UV_COMPILE_BYTECODE=1
ENV UV_LINK_MODE=copy
# Install build tools (only needed for compilation)
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
gcc \
g++ \
&& rm -rf /var/lib/apt/lists/*
# ============================================
# BUILDER STANDARD - Compile standard deps
# ============================================
FROM builder-base AS builder-standard
# Create virtual environment explicitly
RUN uv venv .venv
# Copy dependency files first for better layer caching
COPY pyproject.toml uv.lock ./
COPY agent-memory-client ./agent-memory-client
# Install dependencies into the venv (without the project)
RUN --mount=type=cache,target=/root/.cache/uv \
VIRTUAL_ENV=/app/.venv uv sync --frozen --no-install-project --no-dev
# Copy source code
COPY . /app
# Install the project itself
RUN --mount=type=cache,target=/root/.cache/uv \
. .venv/bin/activate && \
uv pip install --no-deps .
# ============================================
# BUILDER AWS - Compile AWS deps
# ============================================
FROM builder-base AS builder-aws
# Create virtual environment explicitly
RUN uv venv .venv
# Copy dependency files first for better layer caching
COPY pyproject.toml uv.lock ./
COPY agent-memory-client ./agent-memory-client
# Install dependencies into the venv (without the project)
RUN --mount=type=cache,target=/root/.cache/uv \
VIRTUAL_ENV=/app/.venv uv sync --frozen --no-install-project --no-dev --extra aws
# Copy source code
COPY . /app
# Install the project itself
RUN --mount=type=cache,target=/root/.cache/uv \
. .venv/bin/activate && \
uv pip install --no-deps .
# ============================================
# RUNTIME BASE - Slim image without build tools
# ============================================
FROM python:3.12-slim-bookworm AS runtime-base
# OCI labels for Docker Hub and container registries
LABEL org.opencontainers.image.title="Redis Agent Memory Server"
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."
LABEL org.opencontainers.image.url="https://github.com/redis/agent-memory-server"
LABEL org.opencontainers.image.source="https://github.com/redis/agent-memory-server"
LABEL org.opencontainers.image.documentation="https://redis.github.io/agent-memory-server/"
LABEL org.opencontainers.image.vendor="Redis"
LABEL org.opencontainers.image.licenses="Apache-2.0"
WORKDIR /app
# Install only runtime dependencies (curl for healthcheck)
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
&& rm -rf /var/lib/apt/lists/*
# Create non-root user for security
RUN groupadd -r agentmemory && useradd -r -g agentmemory agentmemory
# ============================================
# STANDARD VARIANT - OpenAI/Anthropic only
# ============================================
FROM runtime-base AS standard
# Copy the virtual environment and app from builder
COPY --chown=agentmemory:agentmemory --from=builder-standard /app /app
ENV PATH="/app/.venv/bin:$PATH"
# Switch to non-root user
USER agentmemory
EXPOSE 8000
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD curl -f http://localhost:8000/v1/health || exit 1
# Enable authentication by default.
# You may override with DISABLE_AUTH=true in development.
ENV DISABLE_AUTH=false
# Default to development mode using the API's default backend (Docket). For
# single-process development without a worker, add `--task-backend=asyncio` to
# the api command.
# Examples:
# Development: docker run -p 8000:8000 redislabs/agent-memory-server agent-memory api --host 0.0.0.0 --port 8000 --task-backend=asyncio
# Production API: docker run -p 8000:8000 redislabs/agent-memory-server agent-memory api --host 0.0.0.0 --port 8000
# Production Worker: docker run redislabs/agent-memory-server agent-memory task-worker --concurrency 10
CMD ["agent-memory", "api", "--host", "0.0.0.0", "--port", "8000"]
# ============================================
# AWS VARIANT - Includes AWS Bedrock support
# ============================================
FROM runtime-base AS aws
# Copy the virtual environment and app from builder
COPY --chown=agentmemory:agentmemory --from=builder-aws /app /app
ENV PATH="/app/.venv/bin:$PATH"
# Switch to non-root user
USER agentmemory
EXPOSE 8000
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD curl -f http://localhost:8000/v1/health || exit 1
# Enable authentication by default.
# You may override with DISABLE_AUTH=true in development.
ENV DISABLE_AUTH=false
# Default to development mode using the API's default backend (Docket). For
# single-process development without a worker, add `--task-backend=asyncio` to
# the api command.
# Examples:
# Development: docker run -p 8000:8000 redislabs/agent-memory-server:aws agent-memory api --host 0.0.0.0 --port 8000 --task-backend=asyncio
# Production API: docker run -p 8000:8000 redislabs/agent-memory-server:aws agent-memory api --host 0.0.0.0 --port 8000
# Production Worker: docker run redislabs/agent-memory-server:aws agent-memory task-worker --concurrency 10
CMD ["agent-memory", "api", "--host", "0.0.0.0", "--port", "8000"]