File size: 1,190 Bytes
b985152
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
FROM python:3.11-slim-bullseye

# Install system dependencies
RUN sed -i 's/main/main contrib non-free/' /etc/apt/sources.list && \
    apt-get update && \
    apt-get install -y --no-install-recommends \
    unrar \
    libgl1 \
    libglib2.0-0 \
    && rm -rf /var/lib/apt/lists/*
    
WORKDIR /app

# Upgrade pip and install core dependencies first
RUN pip install --no-cache-dir --upgrade pip setuptools wheel packaging

# Install CPU-only PyTorch first

# Copy requirements and install with special handling for flash_attn
COPY requirements.txt .
RUN pip install --no-cache-dir \
    -r requirements.txt \
    --find-links https://download.pytorch.org/whl/cpu \
    --extra-index-url https://pypi.org/simple && \
# Install remaining packages that might have been skipped
    pip install --no-cache-dir \
    accelerate \
    transformers==4.36.2 \
    timm==0.9.12 \
    einops==0.7.0

# Copy application code
COPY . .

# Create non-root user
RUN useradd -m -u 1000 user && \
    chown -R user:user /app

USER user

# Environment variables to suppress warnings
ENV HF_HUB_DISABLE_PROGRESS=1
ENV TF_CPP_MIN_LOG_LEVEL=3

CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]