1- FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim
1+ # ============================================
2+ # BUILDER BASE - Build tools for compilation
3+ # ============================================
4+ FROM python:3.12-slim-bookworm AS builder-base
5+
6+ WORKDIR /app
7+
8+ # Copy uv binary from official image
9+ COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
10+
11+ ENV UV_COMPILE_BYTECODE=1
12+ ENV UV_LINK_MODE=copy
13+
14+ # Install build tools (only needed for compilation)
15+ RUN apt-get update && apt-get install -y --no-install-recommends \
16+ build-essential \
17+ gcc \
18+ g++ \
19+ && rm -rf /var/lib/apt/lists/*
20+
21+ # ============================================
22+ # BUILDER STANDARD - Compile standard deps
23+ # ============================================
24+ FROM builder-base AS builder-standard
25+
26+ # Create virtual environment explicitly
27+ RUN uv venv .venv
28+
29+ # Copy dependency files first for better layer caching
30+ COPY pyproject.toml uv.lock ./
31+ COPY agent-memory-client ./agent-memory-client
32+
33+ # Install dependencies into the venv (without the project)
34+ RUN --mount=type=cache,target=/root/.cache/uv \
35+ VIRTUAL_ENV=/app/.venv uv sync --frozen --no-install-project --no-dev
36+
37+ # Copy source code
38+ COPY . /app
39+
40+ # Install the project itself
41+ RUN --mount=type=cache,target=/root/.cache/uv \
42+ . .venv/bin/activate && \
43+ uv pip install --no-deps .
44+
45+ # ============================================
46+ # BUILDER AWS - Compile AWS deps
47+ # ============================================
48+ FROM builder-base AS builder-aws
49+
50+ # Create virtual environment explicitly
51+ RUN uv venv .venv
52+
53+ # Copy dependency files first for better layer caching
54+ COPY pyproject.toml uv.lock ./
55+ COPY agent-memory-client ./agent-memory-client
56+
57+ # Install dependencies into the venv (without the project)
58+ RUN --mount=type=cache,target=/root/.cache/uv \
59+ VIRTUAL_ENV=/app/.venv uv sync --frozen --no-install-project --no-dev --extra aws
60+
61+ # Copy source code
62+ COPY . /app
63+
64+ # Install the project itself
65+ RUN --mount=type=cache,target=/root/.cache/uv \
66+ . .venv/bin/activate && \
67+ uv pip install --no-deps .
68+
69+ # ============================================
70+ # RUNTIME BASE - Slim image without build tools
71+ # ============================================
72+ FROM python:3.12-slim-bookworm AS runtime-base
273
374# OCI labels for Docker Hub and container registries
475LABEL org.opencontainers.image.title="Redis Agent Memory Server"
@@ -11,46 +82,35 @@ LABEL org.opencontainers.image.licenses="Apache-2.0"
1182
1283WORKDIR /app
1384
14- ENV UV_COMPILE_BYTECODE=1
15- ENV UV_LINK_MODE=copy
16-
17- # Install system dependencies including build tools
18- RUN apt-get update && apt-get install -y \
85+ # Install only runtime dependencies (curl for healthcheck)
86+ RUN apt-get update && apt-get install -y --no-install-recommends \
1987 curl \
20- build-essential \
21- gcc \
22- g++ \
2388 && rm -rf /var/lib/apt/lists/*
2489
25- RUN --mount=type=cache,target=/root/.cache/uv \
26- --mount=type=bind,source=uv.lock,target=uv.lock \
27- --mount=type=bind,source=pyproject.toml,target=pyproject.toml \
28- --mount=type=bind,source=agent-memory-client,target=agent-memory-client \
29- uv sync --frozen --no-install-project --no-dev
90+ # Create non-root user for security
91+ RUN groupadd -r agentmemory && useradd -r -g agentmemory agentmemory
3092
31- ADD . /app
32- RUN --mount=type=cache,target=/root/.cache/uv \
33- uv sync --frozen --no-dev
93+ # ============================================
94+ # STANDARD VARIANT - OpenAI/Anthropic only
95+ # ============================================
96+ FROM runtime-base AS standard
3497
35- # Create non-root user for security
36- RUN groupadd -r agentmemory && useradd -r -g agentmemory agentmemory && \
37- chown -R agentmemory:agentmemory /app
98+ # Copy the virtual environment and app from builder
99+ COPY --chown=agentmemory:agentmemory --from=builder-standard /app /app
38100
39101ENV PATH="/app/.venv/bin:$PATH"
40102
41103# Switch to non-root user
42104USER agentmemory
43105
44- ENTRYPOINT []
45-
46106EXPOSE 8000
47107
48108HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
49109 CMD curl -f http://localhost:8000/v1/health || exit 1
50110
51- # Disable auth by default for easier local development .
52- # Override with DISABLE_AUTH=false in production .
53- ENV DISABLE_AUTH=true
111+ # Enable authentication by default.
112+ # You may override with DISABLE_AUTH=true in development .
113+ ENV DISABLE_AUTH=false
54114
55115# Default to development mode (no separate worker needed).
56116# For production, override the command to remove --no-worker and run a separate task-worker container.
@@ -59,3 +119,33 @@ ENV DISABLE_AUTH=true
59119# Production API: docker run -p 8000:8000 redislabs/agent-memory-server agent-memory api --host 0.0.0.0 --port 8000
60120# Production Worker: docker run redislabs/agent-memory-server agent-memory task-worker --concurrency 10
61121CMD ["agent-memory" , "api" , "--host" , "0.0.0.0" , "--port" , "8000" , "--no-worker" ]
122+
123+ # ============================================
124+ # AWS VARIANT - Includes AWS Bedrock support
125+ # ============================================
126+ FROM runtime-base AS aws
127+
128+ # Copy the virtual environment and app from builder
129+ COPY --chown=agentmemory:agentmemory --from=builder-aws /app /app
130+
131+ ENV PATH="/app/.venv/bin:$PATH"
132+
133+ # Switch to non-root user
134+ USER agentmemory
135+
136+ EXPOSE 8000
137+
138+ HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
139+ CMD curl -f http://localhost:8000/v1/health || exit 1
140+
141+ # Enable authentication by default.
142+ # You may override with DISABLE_AUTH=true in development.
143+ ENV DISABLE_AUTH=false
144+
145+ # Default to development mode (no separate worker needed).
146+ # For production, override the command to remove --no-worker and run a separate task-worker container.
147+ # Examples:
148+ # Development: docker run -p 8000:8000 redislabs/agent-memory-server:aws
149+ # Production API: docker run -p 8000:8000 redislabs/agent-memory-server:aws agent-memory api --host 0.0.0.0 --port 8000
150+ # Production Worker: docker run redislabs/agent-memory-server:aws agent-memory task-worker --concurrency 10
151+ CMD ["agent-memory" , "api" , "--host" , "0.0.0.0" , "--port" , "8000" , "--no-worker" ]
0 commit comments