File size: 915 Bytes
25ae7fe
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
FROM python:3.10-slim

# Hugging Face Optimized - Lightweight & Stable
ENV PYTHONUNBUFFERED=1
ENV HF_SPACE=1

# Install minimal system dependencies
RUN apt-get update && apt-get install -y \
    curl \
    ffmpeg \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /app

# Copy requirements and install
COPY requirements.txt .
RUN pip install --no-cache-dir --upgrade -r requirements.txt

# Create a non-privileged user (Required by Hugging Face)
RUN useradd -m -u 1000 user
RUN chown -R user:user /app
USER user
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH

# Copy application code
COPY --chown=user:user . .

# Hugging Face uses port 7860
EXPOSE 7860
ENV PORT=7860

# Start the application with optimized settings for limited RAM
# We use 1 worker to keep memory usage low on the free tier
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1", "--timeout-keep-alive", "60"]