File size: 1,156 Bytes
2791744
 
 
 
 
 
 
 
 
 
f1708b4
2791744
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58d1a44
 
 
2791744
 
 
36e7b94
 
2791744
 
36e7b94
 
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
# Use Python 3.9 slim image as base
FROM python:3.9-slim

# Set working directory
WORKDIR /app

# Install system dependencies
RUN apt-get update && apt-get install -y \
    gcc \
    g++ \
    libgl1 \
    libglib2.0-0 \
    libsm6 \
    libxext6 \
    libxrender-dev \
    libgomp1 \
    curl \
    && rm -rf /var/lib/apt/lists/*

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

# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt

# Copy the application code
COPY . .

# Create necessary directories
RUN mkdir -p Models static uploads

# Set environment variables for Hugging Face Spaces
ENV PYTHONPATH=/app
ENV PORT=7860

# Set Hugging Face cache to a writable directory
ENV HF_HOME=/data/hf_cache
RUN mkdir -p /data/hf_cache
# Expose the port
EXPOSE 7860

# Health check - simplified and more tolerant
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=5 \
    CMD curl -f http://localhost:7860/api/health || exit 1

# Command to run the application - use app:app format for HF Spaces
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--timeout-keep-alive", "30"]