File size: 2,068 Bytes
628f94d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102c266
 
 
628f94d
 
 
 
 
 
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
45
46
47
48
# ──────────────────────────────────────────────────────────────────
#  Jigarzzz❀️ β€” Hugging Face Spaces Dockerfile
#  Python 3.11 slim + FFmpeg + all deps
# ──────────────────────────────────────────────────────────────────
FROM python:3.11-slim

# Install system deps: FFmpeg + ImageMagick (for moviepy text clips) + fonts
RUN apt-get update && apt-get install -y --no-install-recommends \
    ffmpeg \
    imagemagick \
    libmagic1 \
    fonts-dejavu-core \
    fonts-liberation \
    curl \
    && rm -rf /var/lib/apt/lists/*

# ImageMagick policy fix β€” allow reading/writing all file types (needed by moviepy)
RUN sed -i 's/rights="none" pattern="PDF"/rights="read|write" pattern="PDF"/' /etc/ImageMagick-6/policy.xml 2>/dev/null || true && \
    sed -i 's/<policy domain="path" rights="none" pattern="@\*"\/>//' /etc/ImageMagick-6/policy.xml 2>/dev/null || true

# Set working directory
WORKDIR /app

# Copy and install Python dependencies first (for layer caching)
COPY requirements.txt .
RUN pip install --no-cache-dir --upgrade pip && \
    pip install --no-cache-dir -r requirements.txt && \
    pip install --no-cache-dir gunicorn Pillow requests

# Copy application source
COPY . .

# Create writable directories for uploads and outputs
RUN mkdir -p uploads outputs && chmod 777 uploads outputs

# Hugging Face Spaces requires the app to listen on port 7860
ENV PORT=7860
ENV HOST=0.0.0.0
# Point moviepy/imageio at system FFmpeg instead of trying to download its own
ENV IMAGEIO_FFMPEG_EXE=/usr/bin/ffmpeg
ENV FFMPEG_BINARY=/usr/bin/ffmpeg

# Expose port
EXPOSE 7860

# Run with gunicorn β€” 1 worker, 4 threads, 300s timeout for long video jobs
CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--workers", "1", "--threads", "4", "--timeout", "300", "--access-logfile", "-", "app:app"]