Spaces:
Sleeping
Sleeping
Gokul commited on
Commit ·
baa021f
1
Parent(s): d92e924
Fix Timeout: Use pre-built AI engine
Browse files- 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
|
| 8 |
RUN useradd -m -u 1000 user
|
| 9 |
USER user
|
| 10 |
ENV PATH="/home/user/.local/bin:$PATH"
|
| 11 |
|
| 12 |
-
# 4. Install system
|
| 13 |
USER root
|
| 14 |
-
RUN apt-get update && apt-get install -y
|
| 15 |
USER user
|
| 16 |
|
| 17 |
-
# 5.
|
| 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 |
-
|
| 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 |
-
#
|
| 27 |
-
RUN
|
| 28 |
|
| 29 |
-
#
|
| 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 |
-
#
|
|
|
|
| 34 |
COPY --chown=user . .
|
| 35 |
|
| 36 |
-
#
|
| 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"]
|