File size: 1,032 Bytes
da636fb
bd5df39
 
 
 
 
 
 
da636fb
 
bd5df39
da636fb
bd5df39
 
da636fb
bd5df39
 
da636fb
bd5df39
 
da636fb
bd5df39
 
 
 
da636fb
 
bd5df39
 
 
 
da636fb
bd5df39
 
da636fb
bd5df39
 
da636fb
bd5df39
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
# Use an official Python runtime
FROM python:3.10-slim

# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
ENV HOME=/home/user

# Install system dependencies
# We use libgl1 instead of libgl1-mesa-glx for newer Debian compatibility
RUN apt-get update && apt-get install -y \
    libgl1 \
    libglib2.0-0 \
    ffmpeg \
    procps \
    && rm -rf /var/lib/apt/lists/*

# Create a non-root user (Required by Hugging Face)
RUN useradd -m -u 1000 user
USER user
ENV PATH="/home/user/.local/bin:${PATH}"
WORKDIR $HOME/app

# Copy requirements and install
COPY --chown=user requirements.txt .
RUN pip install --no-cache-dir --upgrade pip && \
    pip install --no-cache-dir -r requirements.txt

# Copy the rest of the application code
COPY --chown=user . .

# Create storage directories and ensure they are writable
RUN mkdir -p uploads outputs && chmod 777 uploads outputs

# Expose the port HF expects
EXPOSE 7860

# Start the FastAPI app
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]