Gokul commited on
Commit
baa021f
·
1 Parent(s): d92e924

Fix Timeout: Use pre-built AI engine

Browse files
Files changed (1) hide show
  1. Dockerfile +15 -15
Dockerfile CHANGED
@@ -1,37 +1,37 @@
1
- # 1. Use Python 3.10 Slim
2
  FROM python:3.10-slim
3
 
4
  # 2. Set working directory
5
  WORKDIR /app
6
 
7
- # 3. Create a non-root user (Security requirement)
8
  RUN useradd -m -u 1000 user
9
  USER user
10
  ENV PATH="/home/user/.local/bin:$PATH"
11
 
12
- # 4. Install system dependencies for compiling llama-cpp
13
  USER root
14
- RUN apt-get update && apt-get install -y build-essential cmake
15
  USER user
16
 
17
- # 5. Install Python dependencies
18
  COPY --chown=user requirements.txt .
 
 
 
19
  RUN pip install --no-cache-dir --upgrade pip
20
- # Force install CPU-optimized torch
21
  RUN pip install --no-cache-dir torch --index-url https://download.pytorch.org/whl/cpu
22
- # Install llama-cpp-python (CPU optimized)
23
- RUN CMAKE_ARGS="-DGGML_BLAS=OFF" pip install --no-cache-dir llama-cpp-python
24
- RUN pip install --no-cache-dir -r requirements.txt
25
 
26
- # 6. Pre-download the "Embedding" Model (Fast Search)
27
- RUN python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('all-mpnet-base-v2')"
28
 
29
- # 7. Pre-download the "Reasoning" Model (The Customs Officer)
30
- # We download the 4-bit Quantized version (~4.7GB)
31
  RUN huggingface-cli download Qwen/Qwen2.5-7B-Instruct-GGUF qwen2.5-7b-instruct-q4_k_m.gguf --local-dir ./models --local-dir-use-symlinks False
32
 
33
- # 8. Copy app code
 
34
  COPY --chown=user . .
35
 
36
- # 9. Start Server
37
  CMD ["uvicorn", "api.index:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
+ # 1. Use Python 3.10 Slim (Lightweight & Fast)
2
  FROM python:3.10-slim
3
 
4
  # 2. Set working directory
5
  WORKDIR /app
6
 
7
+ # 3. Create a non-root user (Security Best Practice for Spaces)
8
  RUN useradd -m -u 1000 user
9
  USER user
10
  ENV PATH="/home/user/.local/bin:$PATH"
11
 
12
+ # 4. Install system basics (curl is needed for healthchecks)
13
  USER root
14
+ RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
15
  USER user
16
 
17
+ # 5. Copy requirements first (to cache dependencies)
18
  COPY --chown=user requirements.txt .
19
+
20
+ # 6. ⚡ THE SPEED FIX: Install Pre-built AI Engine
21
+ # This downloads the binary instead of building it from source (saves 40 mins)
22
  RUN pip install --no-cache-dir --upgrade pip
 
23
  RUN pip install --no-cache-dir torch --index-url https://download.pytorch.org/whl/cpu
24
+ RUN pip install --no-cache-dir llama-cpp-python --extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cpu
 
 
25
 
26
+ # 7. Install other requirements
27
+ RUN pip install --no-cache-dir -r requirements.txt
28
 
29
+ # 8. Download the Qwen Model (5GB) directly into the image
 
30
  RUN huggingface-cli download Qwen/Qwen2.5-7B-Instruct-GGUF qwen2.5-7b-instruct-q4_k_m.gguf --local-dir ./models --local-dir-use-symlinks False
31
 
32
+ # 9. Copy ALL your custom logic and JSON data
33
+ # This ensures beploo_legal_notes.json, etc. are included
34
  COPY --chown=user . .
35
 
36
+ # 10. Start the Universal Reasoning Agent
37
  CMD ["uvicorn", "api.index:app", "--host", "0.0.0.0", "--port", "7860"]