File size: 1,192 Bytes
b174cf9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Hugging Face Spaces optimized Dockerfile for OmniParser UI Detector
FROM python:3.10-slim

# Set environment variables
ENV PYTHONUNBUFFERED=1 \
    OMP_NUM_THREADS=4 \
    TRANSFORMERS_CACHE=/app/models \
    PADDLEOCR_HOME=/app/paddle_models

# Install system dependencies
RUN apt-get update && apt-get install -y \
    build-essential \
    git \
    libopenblas-dev \
    liblapack-dev \
    libgomp1 \
    libsm6 \
    libxext6 \
    libxrender-dev \
    && rm -rf /var/lib/apt/lists/*

# Set working directory
WORKDIR /app

# Copy requirements
COPY requirements_hf_spaces.txt requirements.txt .

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

# Copy application code
COPY . .

# Create directories for models, cache, and outputs
RUN mkdir -p /app/models /app/paddle_models /tmp/omoi_cropped_images /app/output /app/data

# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=120s --retries=3 \
    CMD python -c "import requests; requests.get('http://localhost:7860/api/health')" || exit 1

# Run the FastAPI server (port 7860 for HF Spaces)
CMD ["python", "app_hf_spaces_server.py", "--port", "7860", "--host", "0.0.0.0"]