File size: 1,955 Bytes
9677b26
8be8b4b
9677b26
 
8be8b4b
9677b26
8be8b4b
 
9677b26
8be8b4b
9677b26
 
 
8be8b4b
 
9677b26
 
8be8b4b
9677b26
 
8be8b4b
9677b26
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8be8b4b
9677b26
 
8be8b4b
 
9677b26
 
 
 
 
 
 
 
 
 
 
 
 
 
8be8b4b
9677b26
 
 
8be8b4b
9677b26
8be8b4b
 
9677b26
 
 
 
 
8be8b4b
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
FROM python:3.10-slim

# Set working directory
WORKDIR /app

# Install system dependencies needed for video generation
RUN apt-get update && apt-get install -y \
    git \
    git-lfs \
    ffmpeg \
    libsndfile1 \
    build-essential \
    curl \
    && rm -rf /var/lib/apt/lists/*

# Initialize git-lfs for large file support
RUN git lfs install

# Upgrade pip and install build tools first
RUN pip install --upgrade pip setuptools wheel

# Create necessary directories with proper permissions for HF Spaces
RUN mkdir -p /tmp/gradio_flagged \
    /tmp/matplotlib \
    /tmp/huggingface \
    /tmp/huggingface/transformers \
    /tmp/huggingface/datasets \
    /tmp/huggingface/hub \
    /app/outputs \
    /app/pretrained_models \
    /app/configs \
    /app/scripts \
    /app/examples \
    && chmod -R 777 /tmp \
    && chmod -R 777 /app/outputs \
    && chmod -R 777 /app/pretrained_models

# Copy requirements first for better caching
COPY requirements.txt .

# Install Python dependencies with increased timeout for video packages
RUN pip install --no-cache-dir --timeout=1000 --retries=3 -r requirements.txt

# Copy application code
COPY . .

# Set environment variables optimized for video generation
ENV PYTHONPATH=/app
ENV PYTHONUNBUFFERED=1
ENV MPLCONFIGDIR=/tmp/matplotlib
ENV GRADIO_ALLOW_FLAGGING=never
ENV HF_HOME=/tmp/huggingface
ENV HF_DATASETS_CACHE=/tmp/huggingface/datasets
ENV HUGGINGFACE_HUB_CACHE=/tmp/huggingface/hub

# Optimize for video generation
ENV TORCH_HOME=/tmp/torch
ENV CUDA_VISIBLE_DEVICES=0

# Create gradio temp directory
RUN mkdir -p /tmp/gradio && chmod -R 777 /tmp/gradio
ENV GRADIO_TEMP_DIR=/tmp/gradio

# Expose port (HuggingFace Spaces uses 7860)
EXPOSE 7860

# Health check optimized for video generation app
HEALTHCHECK --interval=30s --timeout=30s --start-period=120s --retries=3 \
    CMD curl -f http://localhost:7860/health || exit 1

# Run the video generation application
CMD ["python", "app.py"]