File size: 1,787 Bytes
a9dcc35
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
74
75
FROM python:3.10

# Set working directory
WORKDIR /app

# Install system dependencies
RUN apt-get update && apt-get install -y \
    git \
    git-lfs \
    ffmpeg \
    libsm6 \
    libxext6 \
    cmake \
    rsync \
    libgl1 \
    libcairo2-dev \
    pkg-config \
    python3-dev \
    libpango1.0-dev \
    texlive-latex-recommended \
    texlive-fonts-recommended \
    texlive-latex-extra \
    fonts-dejavu-core \
    libsndfile1 \
    && rm -rf /var/lib/apt/lists/* \
    && git lfs install

# Upgrade pip
RUN pip install --no-cache-dir pip -U

# Install HuggingFace dependencies
RUN pip install --no-cache-dir \
    datasets \
    "huggingface-hub>=0.30" \
    "hf-transfer>=0.1.4" \
    "protobuf<4" \
    "click<8.1" \
    "pydantic~=1.0"

# Copy requirements and install Python dependencies
COPY requirements.txt /app/requirements.txt
RUN pip install --no-cache-dir -r /app/requirements.txt

# Install Streamlit and required packages
RUN pip install --no-cache-dir \
    streamlit==1.42.0 \
    "uvicorn>=0.14.0" \
    spaces

# Copy application files
COPY . /app

# Create necessary directories
RUN mkdir -p .streamlit && \
    git config --global core.excludesfile ~/.gitignore && \
    echo ".streamlit" > ~/.gitignore

# Create user directory
RUN mkdir -p /home/user && \
    ( [ -e /home/user/app ] || ln -s /app/ /home/user/app ) || true

# Expose port
EXPOSE 7860

# Set environment variables
ENV GRADIO_SERVER_NAME="0.0.0.0"
ENV STREAMLIT_SERVER_PORT=7860
ENV STREAMLIT_SERVER_ADDRESS=0.0.0.0

# Health check
HEALTHCHECK CMD curl --fail http://localhost:7860/_stcore/health || exit 1

# Run the application
CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0"]