File size: 1,014 Bytes
d70e11e
 
 
 
c2abe3b
d70e11e
 
 
c2abe3b
 
 
 
 
 
 
d70e11e
 
c2abe3b
 
 
 
 
057a2b4
 
8ab5e4c
d70e11e
 
 
36352d8
d70e11e
36352d8
d70e11e
 
 
 
 
 
 
8e311da
 
 
d70e11e
c2abe3b
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
FROM python:3.10-slim

WORKDIR /app

# Fix for numpy and torch compatibility
RUN apt-get update && apt-get install -y \
    git \
    build-essential \
    libopenblas-dev \
    liblapack-dev \
    libffi-dev \
    libglib2.0-0 \
    libsm6 \
    libxext6 \
    libxrender-dev \
    && rm -rf /var/lib/apt/lists/*

# Create cache dirs
RUN mkdir -p /app/.cache && chmod 777 /app/.cache
RUN mkdir -p /app/.cache/torch && chmod 777 /app/.cache/torch
RUN mkdir -p /app/.cache/transformers && chmod 777 /app/.cache/transformers

COPY requirements.txt .

RUN pip install --no-cache-dir -r requirements.txt

RUN git clone https://github.com/apple/ml-mobileclip.git && \
    cd ml-mobileclip && \
    pip install -e . --no-deps && \
    cd .. && \
    rm -rf ml-mobileclip/.git

COPY app.py .

EXPOSE 7860

ENV PYTHONPATH=/app
ENV PYTHONUNBUFFERED=1
ENV HF_HOME=/app/.cache
ENV TORCH_HOME=/app/.cache/torch
ENV TRANSFORMERS_CACHE=/app/.cache/transformers

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