Repository navigation
Expand file tree
/
Copy pathDockerfile.classifier
More file actions
48 lines (39 loc) · 1.91 KB
/
Copy pathDockerfile.classifier
File metadata and controls
48 lines (39 loc) · 1.91 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
# Classification half of the split: runs the ML inference off Lambda so it is
# not capped by Lambda's 10GB image/memory limits. CPU torch (same index trick
# as Dockerfile.lambda) keeps the image small; the inference code auto-selects
# cuda when available, but this image intentionally installs CPU-only PyTorch.
# A separately tested CUDA image is required before enabling GPU inference.
FROM python:3.11-slim
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1 \
MODEL_CACHE_DIR=/models \
LOCAL_MODELS_DIR=/models \
HF_HOME=/models/hf \
TRANSFORMERS_CACHE=/models/hf
WORKDIR /app
# System deps mirror the web Dockerfile (known-good for this dependency set).
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential gcc g++ pkg-config \
libcairo2-dev libgirepository1.0-dev libpq-dev \
&& rm -rf /var/lib/apt/lists/*
RUN pip install --upgrade pip setuptools wheel
# CPU torch index primary so torch resolves to the +cpu wheel (no CUDA/nvidia libs);
# everything else falls through to PyPI.
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt \
--index-url https://download.pytorch.org/whl/cpu \
--extra-index-url https://pypi.org/simple
# Bake the spaCy model in; the code otherwise downloads it at runtime.
RUN python -m spacy download en_core_web_sm
COPY manage.py .
COPY dashboard/ ./dashboard/
COPY config/ ./config/
# The inference API shares this image (it also needs the ML stack); it boots via
# gunicorn config.inference_wsgi:application (see docker-compose.inference.yml).
COPY inference_api/ ./inference_api/
VOLUME ["/models"]
EXPOSE 8000
# Production-safe default for the dedicated Dokku inference application. Local
# batch-classifier Compose explicitly overrides this command.
CMD ["gunicorn", "config.inference_wsgi:application", "--workers", "1", "--threads", "2", "--timeout", "180", "--bind", "0.0.0.0:8000"]