Really-amin commited on
Commit
279ffcf
·
verified ·
1 Parent(s): 050a438

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +18 -32
Dockerfile CHANGED
@@ -5,13 +5,13 @@ FROM python:3.10-slim
5
  # Set working directory
6
  WORKDIR /app
7
 
8
- # Set environment variables for better Python behavior
9
  ENV PYTHONUNBUFFERED=1 \
10
  PYTHONDONTWRITEBYTECODE=1 \
11
  PIP_NO_CACHE_DIR=1 \
12
  PIP_DISABLE_PIP_VERSION_CHECK=1
13
 
14
- # Install system dependencies required for building Python packages
15
  RUN apt-get update && apt-get install -y --no-install-recommends \
16
  gcc \
17
  g++ \
@@ -22,50 +22,36 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
22
  # Copy requirements first for better layer caching
23
  COPY requirements.txt .
24
 
25
- # Install Python dependencies with optimizations
26
- # Split into two steps: core dependencies first, then ML libraries
27
- RUN pip install --no-cache-dir \
28
- fastapi==0.104.1 \
29
- uvicorn[standard]==0.24.0 \
30
- pydantic==2.5.0 \
31
- python-multipart==0.0.6 \
32
- websockets==12.0 \
33
- SQLAlchemy==2.0.23 \
34
- APScheduler==3.10.4 \
35
- aiohttp==3.9.1 \
36
- requests==2.31.0 \
37
- httpx \
38
- python-dotenv==1.0.0 \
39
- feedparser==6.0.11 \
40
- gradio==4.14.0 \
41
- pandas==2.1.4 \
42
- plotly==5.18.0
43
 
44
- # Install HuggingFace ML dependencies separately
45
  RUN pip install --no-cache-dir \
46
- transformers>=4.44.0 \
47
- datasets>=3.0.0 \
48
- huggingface_hub>=0.24.0 \
49
- torch>=2.0.0 --index-url https://download.pytorch.org/whl/cpu \
50
- sentencepiece>=0.1.99 \
51
- protobuf>=3.20.0
 
52
 
53
  # Copy all application code
54
  COPY . .
55
 
56
  # Create necessary directories
57
- RUN mkdir -p data logs
58
-
59
- # Set proper permissions for data directories
60
- RUN chmod -R 755 data logs
61
 
62
  # Expose port 7860 (HuggingFace Spaces standard port)
63
  EXPOSE 7860
64
 
65
  # Health check endpoint for HuggingFace Spaces
 
 
66
  HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
67
  CMD curl -f http://localhost:7860/health || exit 1
68
 
69
  # Run the FastAPI application with uvicorn
70
- # Using multiple workers for better performance (adjust based on available resources)
71
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--log-level", "info", "--workers", "1"]
 
5
  # Set working directory
6
  WORKDIR /app
7
 
8
+ # Environment variables for better Python behavior
9
  ENV PYTHONUNBUFFERED=1 \
10
  PYTHONDONTWRITEBYTECODE=1 \
11
  PIP_NO_CACHE_DIR=1 \
12
  PIP_DISABLE_PIP_VERSION_CHECK=1
13
 
14
+ # System dependencies required for building Python packages
15
  RUN apt-get update && apt-get install -y --no-install-recommends \
16
  gcc \
17
  g++ \
 
22
  # Copy requirements first for better layer caching
23
  COPY requirements.txt .
24
 
25
+ # Install core Python dependencies from requirements.txt
26
+ # (اینجا دیگه نسخه‌ها فقط از requirements.txt خوانده می‌شن)
27
+ RUN pip install --no-cache-dir -r requirements.txt
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
 
29
+ # Install HuggingFace / ML dependencies separately
30
  RUN pip install --no-cache-dir \
31
+ "transformers>=4.44.0" \
32
+ "datasets>=3.0.0" \
33
+ "huggingface_hub>=0.24.0" \
34
+ "sentencepiece>=0.1.99" \
35
+ "protobuf>=3.20.0" && \
36
+ pip install --no-cache-dir --index-url https://download.pytorch.org/whl/cpu \
37
+ "torch>=2.0.0"
38
 
39
  # Copy all application code
40
  COPY . .
41
 
42
  # Create necessary directories
43
+ RUN mkdir -p data logs && \
44
+ chmod -R 755 data logs
 
 
45
 
46
  # Expose port 7860 (HuggingFace Spaces standard port)
47
  EXPOSE 7860
48
 
49
  # Health check endpoint for HuggingFace Spaces
50
+ # مطمئن شو تو FastAPI روت /health رو داری، مثلاً:
51
+ # @app.get("/health") -> {"status": "ok"}
52
  HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
53
  CMD curl -f http://localhost:7860/health || exit 1
54
 
55
  # Run the FastAPI application with uvicorn
56
+ # UI تو می‌تونه HTML استاتیک باشه؛ مهم اینه FastAPI این‌ها رو سرو کنه
57
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--log-level", "info", "--workers", "1"]