File size: 1,722 Bytes
86f7d50
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
64
65
66
67
68
69
70
71
72
73
74
# Use Python base image with CPU
FROM python:3.10-slim

# Environment setup
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
ENV DEBIAN_FRONTEND=noninteractive

# Install system dependencies
RUN apt-get update && apt-get install -y \
    git \
    wget \
    curl \
    build-essential \
    python3-dev \
    libffi-dev \
    libssl-dev \
    libjpeg-dev \
    libpng-dev \
    libfreetype6-dev \
    pkg-config \
    && rm -rf /var/lib/apt/lists/*

# Set working directory
WORKDIR /app

# Preinstall Python base tools
RUN pip install --no-cache-dir --upgrade pip setuptools wheel

# Install base ML + tokenizers + NLP tools
RUN pip install --no-cache-dir \
    transformers>=4.33.2 \
    sentencepiece \
    sacremoses \
    nltk \
    pandas \
    regex \
    mock \
    mosestokenizer \
    bitsandbytes \
    scipy \
    accelerate \
    datasets

# Download NLTK data
RUN python3 -c "import nltk; nltk.download('punkt')"

# Install FastAPI app dependencies
RUN pip install --no-cache-dir fastapi uvicorn pydantic psutil

# Clone IndicTransToolkit directly to app and install editable
RUN git clone https://github.com/VarunGumma/IndicTransToolkit.git /app/IndicTransToolkit && \
    pip install -e /app/IndicTransToolkit

    # rm -rf /tmp/IndicTransToolkit

# Copy app source
COPY . .

# Create non-root user
RUN useradd --create-home --shell /bin/bash app
RUN chown -R app:app /app
USER app

# Health route port
EXPOSE 7860

# Optional healthcheck (requires you to define GET /health)
HEALTHCHECK --interval=30s --timeout=30s --start-period=60s --retries=3 \
    CMD curl -f http://localhost:7860/health || exit 1

# Run FastAPI
CMD ["python", "-m", "uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]