File size: 1,024 Bytes
a098474
 
881566a
 
 
916734f
881566a
 
 
 
916734f
881566a
a098474
881566a
916734f
a098474
 
 
916734f
881566a
 
 
 
fbd4f59
881566a
 
916734f
a098474
 
 
916734f
a098474
 
916734f
a098474
 
 
881566a
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
FROM python:3.11-slim

ENV PYTHONDONTWRITEBYTECODE=1 \
    PYTHONUNBUFFERED=1

# System deps you actually use
RUN apt-get update && apt-get install -y --no-install-recommends \
    tesseract-ocr ffmpeg && \
    rm -rf /var/lib/apt/lists/*

# Writable dirs + non-root
RUN useradd -m appuser && mkdir -p /app /data/cache && chown -R appuser:appuser /app /data
WORKDIR /app

# Python deps
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt

# Hugging Face caches in /data (NOT /.cache)
ENV HF_HOME=/data/cache/huggingface \
    TRANSFORMERS_CACHE=/data/cache/huggingface/hub \
    SENTENCE_TRANSFORMERS_HOME=/data/cache/sentence-transformers \
    XDG_CACHE_HOME=/data/cache

USER appuser

# Pre-cache the embed model (optional)
RUN python - <<'PY'
from sentence_transformers import SentenceTransformer
SentenceTransformer('intfloat/e5-small-v2')
print('✅ cached e5-small-v2')
PY

# App code
COPY . ./

ENV PORT=7860
CMD ["bash","-lc","gunicorn -w 1 -k gthread --threads 8 -b 0.0.0.0:$PORT main:app"]