File size: 753 Bytes
6b7d99c
 
 
 
32f5b59
15a4429
32f5b59
 
15a4429
6b7d99c
c9d68fb
32f5b59
15a4429
 
32f5b59
15a4429
 
32f5b59
 
15a4429
32f5b59
 
 
 
6b7d99c
 
 
32f5b59
 
 
 
15a4429
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
FROM python:3.10-slim

WORKDIR /app

# Install system dependencies (git is needed for some transformers models)
RUN apt-get update && \
    apt-get install -y git && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*

# Create a directory for cache that will be writable by the user
RUN mkdir -p /cache && chmod a+rwx /cache

# Set environment variables
ENV HF_HOME=/cache
ENV PYTHONUNBUFFERED=1

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

COPY . .

# Fix permissions (in case you're running as non-root)
RUN chmod a+rwx /app

EXPOSE 7860

# Run as non-root user for security
RUN useradd -m myuser && chown -R myuser:myuser /app /cache
USER myuser

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