forked from Lians-ai/Lians
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
51 lines (42 loc) · 2.12 KB
/
Copy pathDockerfile
File metadata and controls
51 lines (42 loc) · 2.12 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
FROM python:3.12-slim
WORKDIR /app
# System deps: gcc + libpq-dev for asyncpg C extension; libffi-dev for cryptography
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
libpq-dev \
libffi-dev \
&& rm -rf /var/lib/apt/lists/*
# Install Python dependencies before copying the full source tree so that
# Docker reuses this layer on code-only changes (pyproject.toml is the cache key).
# [local] installs sentence-transformers for self-hosted, air-gapped deployments.
# Pass --build-arg EXTRAS= to build a leaner image when using EMBEDDING_PROVIDER=voyage.
ARG EXTRAS=local
COPY pyproject.toml ./
COPY agentmem/src/ ./agentmem/src/
RUN pip install --no-cache-dir -e ".[$EXTRAS]"
# Pre-download the sentence-transformers model at build time so:
# (a) first startup requires zero network access
# (b) runtime works with readOnlyRootFilesystem: true (no downloads at startup)
# The model lands in /app/.model_cache (set via SENTENCE_TRANSFORMERS_HOME below).
# Pass --build-arg PREDOWNLOAD_MODEL= to skip the download (e.g. CI, non-local provider).
ARG PREDOWNLOAD_MODEL=BAAI/bge-large-en-v1.5
ENV SENTENCE_TRANSFORMERS_HOME=/app/.model_cache
RUN if [ -n "$PREDOWNLOAD_MODEL" ]; then \
python -c "from sentence_transformers import SentenceTransformer; \
SentenceTransformer('$PREDOWNLOAD_MODEL')"; \
fi
# After baking the model in, tell HuggingFace libraries not to check for updates
# or attempt any network calls. This enforces true air-gap behaviour at runtime.
ENV TRANSFORMERS_OFFLINE=1
ENV HF_DATASETS_OFFLINE=1
# Copy the remaining source (migrations, SDK, examples)
COPY agentmem/ ./agentmem/
# Run from agentmem/ so that:
# - alembic finds alembic.ini in the CWD
# - uvicorn resolves src.lian.main via the CWD on sys.path
WORKDIR /app/agentmem
EXPOSE 8000
# The package is pip-installed (import name "lians") — do not reference the
# src tree by path here; src.lian.main was a stale pre-rename path that made
# the compose api service crash-loop while Render masked it via startCommand.
CMD ["uvicorn", "lians.main:app", "--host", "0.0.0.0", "--port", "8000", "--workers", "2"]