-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.server
More file actions
63 lines (47 loc) · 2.75 KB
/
Copy pathDockerfile.server
File metadata and controls
63 lines (47 loc) · 2.75 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
# ── Stage 1: Build ─────────────────────────────────────────────────
FROM python:3.14-slim AS builder
WORKDIR /build
# Make each --prefix=/install step visible to the next (so the torch install
# below is seen as satisfied and spacy-transformers doesn't refetch CUDA torch).
ENV PYTHONPATH=/install/lib/python3.11/site-packages
RUN apt-get update && apt-get install -y --no-install-recommends gcc libpq-dev \
&& rm -rf /var/lib/apt/lists/*
COPY pyproject.toml README.md ./
COPY src/ src/
# pyproject force-includes these into the wheel, so the build needs them present.
COPY migrations/ migrations/
COPY migrations_sqlite/ migrations_sqlite/
# [ner] adds spaCy so graph entity extraction uses real NER (not the heuristic
# fallback). en_core_web_sm is kept as a small fallback model.
RUN pip install --no-cache-dir --prefix=/install ".[server,enrichment,ner]" \
"https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.8.0/en_core_web_sm-3.8.0-py3-none-any.whl"
# Transformer NER (en_core_web_trf) — the highest-accuracy spaCy model, used by
# default (LORE_GRAPH_SPACY_MODEL=en_core_web_trf below). Install CPU-only torch
# first so spacy-transformers doesn't drag in the multi-GB CUDA build.
RUN pip install --no-cache-dir --prefix=/install \
--index-url https://download.pytorch.org/whl/cpu \
torch \
&& pip install --no-cache-dir --prefix=/install \
spacy-transformers \
"https://github.com/explosion/spacy-models/releases/download/en_core_web_trf-3.8.0/en_core_web_trf-3.8.0-py3-none-any.whl"
# ── Stage 2: Runtime ───────────────────────────────────────────────
FROM python:3.14-slim
WORKDIR /app
# Only runtime lib needed (no gcc)
RUN apt-get update && apt-get install -y --no-install-recommends libpq5 \
&& rm -rf /var/lib/apt/lists/* \
&& groupadd -r lore && useradd -r -g lore -d /app lore
COPY --from=builder /install /usr/local
COPY migrations/ migrations/
COPY src/lore/ui/dist/ /app/ui/dist/
# Create writable dirs for model cache and data
RUN mkdir -p /app/.lore/models /app/data && chown -R lore:lore /app/.lore /app/data
# Use the transformer NER model by default (installed above). Override to
# en_core_web_sm/lg to trade accuracy for image size / CPU speed.
ENV LORE_GRAPH_SPACY_MODEL=en_core_web_trf
# Don't run as root
USER lore
EXPOSE 8765
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8765/health')" || exit 1
CMD ["uvicorn", "lore.server.app:app", "--host", "0.0.0.0", "--port", "8765"]