Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
67 lines (49 loc) · 2.97 KB
/
Copy pathDockerfile
File metadata and controls
67 lines (49 loc) · 2.97 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
# syntax=docker/dockerfile:1
# ── Stage 1: build the wheel ─────────────────────────────────────────────────
FROM python:3.11-slim AS builder
WORKDIR /src
RUN pip install --no-cache-dir --upgrade pip build
# Only what the sdist/wheel needs (see MANIFEST.in / pyproject.toml)
COPY pyproject.toml setup.py MANIFEST.in README.md LICENSE ./
COPY multimind/ multimind/
RUN python -m build --wheel --outdir /wheels
# ── Stage 2: runtime ─────────────────────────────────────────────────────────
FROM python:3.11-slim
LABEL org.opencontainers.image.title="MultiMind SDK" \
org.opencontainers.image.description="Compliance-first AI agent framework — gateway API image" \
org.opencontainers.image.vendor="MultimindLAB" \
org.opencontainers.image.licenses="Apache-2.0" \
org.opencontainers.image.source="https://github.com/multimindlab/multimind-sdk" \
org.opencontainers.image.documentation="https://github.com/multimindlab/multimind-sdk/blob/develop/docs/deployment.md"
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=1 \
MULTIMIND_PORT=8000
RUN groupadd --gid 10001 multimind \
&& useradd --uid 10001 --gid multimind --create-home --shell /usr/sbin/nologin multimind
# Default extras are the API and RAG. Override for a CLI-capable image:
# --build-arg MULTIMIND_EXTRAS=gateway,finetune
ARG MULTIMIND_EXTRAS=gateway,rag
# CPU-only torch first: sentence-transformers (in [rag]) needs torch, and the
# default Linux wheel drags in ~4 GB of unused CUDA libraries on amd64 and arm64.
RUN pip install --no-cache-dir torch --index-url https://download.pytorch.org/whl/cpu
# Core deps + selected extras only. No docs, no tests, no examples.
# numpy: multimind.gateway.api imports multimind.compliance, whose eager
# imports need numpy but nothing else from the heavy [compliance] extra.
RUN --mount=from=builder,source=/wheels,target=/wheels \
pip install --no-cache-dir "$(ls /wheels/multimind_sdk-*.whl)[${MULTIMIND_EXTRAS}]" "numpy>=1.21.0"
# One FastAPI app: gateway, governance, guard proxy, and RAG when installed.
RUN printf '%s\n' \
'import os' \
'import uvicorn' \
'from multimind.server.platform import create_platform_app' \
'uvicorn.run(create_platform_app(), host="0.0.0.0", port=int(os.environ.get("MULTIMIND_PORT", "8000")))' \
> /usr/local/bin/multimind-serve.py
# Writable app dir (chat sessions are stored under the working directory)
WORKDIR /app
RUN chown multimind:multimind /app
USER multimind
EXPOSE 8000
HEALTHCHECK --interval=30s --timeout=5s --start-period=15s --retries=3 \
CMD python -c "import os,urllib.request; urllib.request.urlopen('http://127.0.0.1:' + os.environ.get('MULTIMIND_PORT', '8000') + '/health', timeout=4)"
CMD ["python", "/usr/local/bin/multimind-serve.py"]