File size: 1,213 Bytes
1944d2e
16f57d9
1944d2e
 
 
 
 
 
 
 
16f57d9
 
 
1944d2e
 
 
 
 
 
16f57d9
1944d2e
16f57d9
1944d2e
16f57d9
 
1944d2e
 
 
 
16f57d9
 
1944d2e
 
 
 
 
 
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 \
    PIP_NO_CACHE_DIR=1 \
    HF_HOME=/tmp/huggingface \
    TRANSFORMERS_CACHE=/tmp/huggingface/hub \
    SAFECHAT_CLASSIFIER_MODEL=vineet88/safechat-muril-toxicity-finetuned \
    SAFECHAT_DETOX_MODEL=ai4bharat/IndicBART \
    SAFECHAT_USE_MODEL_DETOX=false

WORKDIR /app

# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
    build-essential \
    && rm -rf /var/lib/apt/lists/*

# Copy requirements first (Docker cache optimization)
COPY requirements.txt .
RUN pip install --upgrade pip && pip install --no-cache-dir -r requirements.txt

# Copy only the runtime payload used by the Space.
COPY app ./app

# Create directories
RUN mkdir -p /app/checkpoints /app/models /tmp/huggingface

# Expose port
EXPOSE 8000

# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=120s --retries=3 \
    CMD python -c "import httpx; r = httpx.get('http://localhost:8000/api/v1/health'); exit(0 if r.status_code == 200 else 1)"

# Run with uvicorn (1 worker — models are loaded per worker)
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--workers", "1"]