File size: 908 Bytes
8e6f164
 
b89edfe
8e6f164
 
9b8e4e2
8e6f164
 
 
b89edfe
 
 
 
 
 
 
 
 
 
 
 
8e6f164
 
b89edfe
 
 
8e6f164
b89edfe
8e6f164
 
 
b89edfe
8e6f164
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
FROM python:3.10-slim

# Install system dependencies needed for OpenCV / PIL
RUN apt-get update && apt-get install -y \
    build-essential \
    libgl1 \
    libglib2.0-0 \
    && rm -rf /var/lib/apt/lists/*

# Set up a new user 'user' with UID 1000 (Hugging Face default)
RUN useradd -m -u 1000 user
USER user
ENV PATH="/home/user/.local/bin:$PATH"
# Configure HF cache to be inside a writable directory
ENV HF_HOME=/tmp/huggingface_cache

WORKDIR /app

# Copy requirements and install packages
COPY --chown=user ./requirements.txt /app/requirements.txt
RUN pip install --no-cache-dir --upgrade -r /app/requirements.txt
RUN pip install --no-cache-dir accelerate

# Copy all application code
COPY --chown=user ./api /app/api
COPY --chown=user ./app.py /app/app.py

# Expose port 7860
ENV PORT=7860
EXPOSE 7860

# Command to run uvicorn
CMD ["uvicorn", "api.main:app", "--host", "0.0.0.0", "--port", "7860"]