forked from omarfarouk228/togolm
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
63 lines (51 loc) · 2.22 KB
/
Copy pathDockerfile
File metadata and controls
63 lines (51 loc) · 2.22 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
# ── Base image ─────────────────────────────────────────────────────────────
FROM python:3.11-slim AS base
WORKDIR /app
# System deps: build essentials + psycopg2 native
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
libpq-dev \
curl \
&& rm -rf /var/lib/apt/lists/*
# ── Dependency layer ────────────────────────────────────────────────────────
FROM base AS deps
# Copy only dependency manifests so Docker cache is invalidated only when
# they change, not on every code edit.
COPY pyproject.toml uv.lock* ./
# Install uv for fast installs, then install API-only dependencies.
RUN pip install --no-cache-dir uv && \
uv pip install --system --no-cache \
fastapi \
"uvicorn[standard]" \
"pydantic[email]" \
python-dotenv \
psycopg2-binary \
pgvector \
sqlalchemy \
sentence-transformers \
"google-genai>=2.3.0" \
redis \
celery \
tqdm
# Pre-download the embedding model (bakes it into the image so cold starts
# don't need internet access to download ~120 MB model weights).
RUN python -c "\
from sentence_transformers import SentenceTransformer; \
SentenceTransformer('paraphrase-multilingual-MiniLM-L12-v2')"
# ── Production image ────────────────────────────────────────────────────────
FROM deps AS production
# Copy application code (excludes everything in .dockerignore)
COPY api/ ./api/
COPY corpus/ ./corpus/
# Non-root user for security
RUN useradd --create-home --shell /bin/bash app
USER app
# Health check (calls the /health endpoint every 30s)
HEALTHCHECK --interval=30s --timeout=10s --start-period=15s --retries=3 \
CMD curl -f http://localhost:8000/health || exit 1
EXPOSE 8000
CMD ["uvicorn", "api.app.main:app", \
"--host", "0.0.0.0", \
"--port", "8000", \
"--workers", "2", \
"--log-level", "info"]