File size: 1,400 Bytes
7cb976c
 
38b66bd
7cb976c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38b66bd
7cb976c
 
38b66bd
7cb976c
 
38b66bd
 
 
 
7cb976c
38b66bd
7cb976c
 
 
 
38b66bd
7cb976c
 
 
 
 
 
 
 
 
 
 
 
38b66bd
7cb976c
 
 
38b66bd
7cb976c
 
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
# Use NVIDIA CUDA base image for GPU support on HuggingFace Spaces
FROM nvidia/cuda:11.8.0-cudnn8-runtime-ubuntu22.04

# Set environment variables
ENV DEBIAN_FRONTEND=noninteractive \
    PYTHONUNBUFFERED=1 \
    GRADIO_SERVER_NAME=0.0.0.0 \
    GRADIO_SERVER_PORT=7860

# Install system dependencies
RUN apt-get update && apt-get install -y \
    python3.10 \
    python3-pip \
    git \
    curl \
    && rm -rf /var/lib/apt/lists/*

# Create symbolic link for python
RUN ln -s /usr/bin/python3.10 /usr/bin/python

# Set up user with ID 1000 (required by HuggingFace Spaces)
RUN useradd -m -u 1000 user

# Switch to user
USER user

# Set home and path
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH

# Set working directory
WORKDIR $HOME/app

# Upgrade pip
RUN pip3 install --no-cache-dir --upgrade pip

# Copy requirements and install (fix NumPy version first)
COPY --chown=user requirements.txt .
RUN pip3 install --no-cache-dir "numpy<2" && \
    pip3 install --no-cache-dir -r requirements.txt

# Copy application files
COPY --chown=user app.py .
COPY --chown=user README.md .

# Create data directory for persistent storage
RUN mkdir -p $HOME/app/data

# Expose Gradio port
EXPOSE 7860

# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
    CMD curl -f http://localhost:7860/ || exit 1

# Run the Gradio application
CMD ["python3", "app.py"]