Really-amin commited on
Commit
12bac91
·
verified ·
1 Parent(s): 6252831

Upload 11 files

Browse files
Files changed (3) hide show
  1. Dockerfile +11 -44
  2. index.html +0 -0
  3. main.py +2 -0
Dockerfile CHANGED
@@ -1,35 +1,22 @@
1
- # Dockerfile for Crypto API Monitoring System
2
- # Optimized for HuggingFace Spaces deployment
3
  FROM python:3.10-slim
4
 
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++ \
18
- git \
19
- curl \
20
  && rm -rf /var/lib/apt/lists/*
21
 
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 \
@@ -41,31 +28,11 @@ RUN pip install --no-cache-dir \
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"]
 
 
 
1
  FROM python:3.10-slim
2
 
 
3
  WORKDIR /app
4
 
5
+ # Copy project files into the image
6
+ COPY . /app
 
 
 
7
 
8
+ # Install system dependencies if needed (optional, keep minimal)
9
  RUN apt-get update && apt-get install -y --no-install-recommends \
10
+ build-essential \
 
 
 
11
  && rm -rf /var/lib/apt/lists/*
12
 
13
+ # Install Python dependencies
14
+ # NOTE: websockets version is NOT pinned to 12.0 to avoid conflict with gradio_client
 
 
 
15
  RUN pip install --no-cache-dir \
16
  fastapi==0.104.1 \
17
  uvicorn[standard]==0.24.0 \
18
  pydantic==2.5.0 \
19
  python-multipart==0.0.6 \
 
20
  SQLAlchemy==2.0.23 \
21
  APScheduler==3.10.4 \
22
  aiohttp==3.9.1 \
 
28
  pandas==2.1.4 \
29
  plotly==5.18.0
30
 
31
+ # Expose the port that Hugging Face expects (7860 by default)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  EXPOSE 7860
33
 
34
+ # For HF Spaces compatibility
35
+ ENV PORT=7860
 
36
 
37
+ # Main entrypoint: use main:app (FastAPI)
38
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860", "--proxy-headers", "--forwarded-allow-ips", "*"]
 
index.html CHANGED
The diff for this file is too large to render. See raw diff
 
main.py CHANGED
@@ -1,3 +1,5 @@
1
  from app import app as fastapi_app
2
 
 
 
3
  app = fastapi_app
 
1
  from app import app as fastapi_app
2
 
3
+ # Uvicorn / Hugging Face entrypoint
4
+ # This file allows us to run: uvicorn main:app ...
5
  app = fastapi_app