File size: 961 Bytes
7f92c1d
 
 
fdbecd2
7f92c1d
 
 
 
670a149
7f92c1d
670a149
7f92c1d
670a149
7f92c1d
d94ff19
 
bd544d3
 
fdbecd2
 
bd544d3
7f92c1d
 
 
 
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
FROM python:3.10-slim

RUN apt-get update && apt-get install -y \
    libgl1 libglib2.0-0 libsm6 libxext6 libxrender-dev \
    && rm -rf /var/lib/apt/lists/*

RUN useradd -m -u 1000 user
USER user

ENV PATH="/home/user/.local/bin:$PATH"
ENV TOKENIZERS_PARALLELISM=false

WORKDIR /app
COPY --chown=user requirements.txt .

RUN pip install --no-cache-dir \
        torch==2.4.0+cpu \
        torchvision==0.19.0+cpu \
        --index-url https://download.pytorch.org/whl/cpu \
    && pip install --no-cache-dir -r requirements.txt \
    && python -c "import torch, torchvision, transformers; from transformers.utils import is_torch_available, is_torchvision_available; assert is_torch_available(), 'torch not detected'; assert is_torchvision_available(), 'torchvision not detected'; print('OK torch', torch.__version__, 'transformers', transformers.__version__)"

COPY --chown=user . .
EXPOSE 7860
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]