makeitfr commited on
Commit
b174cf9
·
verified ·
1 Parent(s): 483b68a

Upload Dockerfile with huggingface_hub

Browse files
Files changed (1) hide show
  1. Dockerfile +42 -0
Dockerfile ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Hugging Face Spaces optimized Dockerfile for OmniParser UI Detector
2
+ FROM python:3.10-slim
3
+
4
+ # Set environment variables
5
+ ENV PYTHONUNBUFFERED=1 \
6
+ OMP_NUM_THREADS=4 \
7
+ TRANSFORMERS_CACHE=/app/models \
8
+ PADDLEOCR_HOME=/app/paddle_models
9
+
10
+ # Install system dependencies
11
+ RUN apt-get update && apt-get install -y \
12
+ build-essential \
13
+ git \
14
+ libopenblas-dev \
15
+ liblapack-dev \
16
+ libgomp1 \
17
+ libsm6 \
18
+ libxext6 \
19
+ libxrender-dev \
20
+ && rm -rf /var/lib/apt/lists/*
21
+
22
+ # Set working directory
23
+ WORKDIR /app
24
+
25
+ # Copy requirements
26
+ COPY requirements_hf_spaces.txt requirements.txt .
27
+
28
+ # Install Python dependencies
29
+ RUN pip install --no-cache-dir -r requirements_hf_spaces.txt
30
+
31
+ # Copy application code
32
+ COPY . .
33
+
34
+ # Create directories for models, cache, and outputs
35
+ RUN mkdir -p /app/models /app/paddle_models /tmp/omoi_cropped_images /app/output /app/data
36
+
37
+ # Health check
38
+ HEALTHCHECK --interval=30s --timeout=10s --start-period=120s --retries=3 \
39
+ CMD python -c "import requests; requests.get('http://localhost:7860/api/health')" || exit 1
40
+
41
+ # Run the FastAPI server (port 7860 for HF Spaces)
42
+ CMD ["python", "app_hf_spaces_server.py", "--port", "7860", "--host", "0.0.0.0"]