Spaces:
Build error
Build error
Commit ·
a9145dc
1
Parent(s): 2a72045
Optimize Dockerfile: skip expensive llama-cpp-python compilation flags
Browse files- Dockerfile +11 -6
Dockerfile
CHANGED
|
@@ -2,19 +2,24 @@ FROM python:3.11-slim
|
|
| 2 |
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
-
# Install system dependencies
|
| 6 |
RUN apt-get update && apt-get install -y \
|
| 7 |
build-essential \
|
|
|
|
| 8 |
libopenblas-dev \
|
| 9 |
tesseract-ocr \
|
| 10 |
libtesseract-dev \
|
|
|
|
| 11 |
&& rm -rf /var/lib/apt/lists/*
|
| 12 |
|
| 13 |
-
#
|
|
|
|
|
|
|
|
|
|
| 14 |
COPY requirements.txt .
|
| 15 |
|
| 16 |
-
# Install
|
| 17 |
-
RUN pip install --no-cache-dir -r requirements.txt
|
| 18 |
|
| 19 |
# Copy application code
|
| 20 |
COPY . .
|
|
@@ -22,8 +27,8 @@ COPY . .
|
|
| 22 |
# Create models directory
|
| 23 |
RUN mkdir -p models
|
| 24 |
|
| 25 |
-
# Expose port 7860
|
| 26 |
EXPOSE 7860
|
| 27 |
|
| 28 |
-
# Run
|
| 29 |
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860", "--timeout-keep-alive", "75"]
|
|
|
|
| 2 |
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
+
# Install system dependencies
|
| 6 |
RUN apt-get update && apt-get install -y \
|
| 7 |
build-essential \
|
| 8 |
+
cmake \
|
| 9 |
libopenblas-dev \
|
| 10 |
tesseract-ocr \
|
| 11 |
libtesseract-dev \
|
| 12 |
+
git \
|
| 13 |
&& rm -rf /var/lib/apt/lists/*
|
| 14 |
|
| 15 |
+
# Pre-build llama-cpp-python with explicit flags to speed up compilation
|
| 16 |
+
RUN CMAKE_ARGS="-DLLAMA_BLAS=OFF -DLLAMA_METAL=OFF" pip install --no-cache-dir --force-reinstall -v llama-cpp-python==0.2.70
|
| 17 |
+
|
| 18 |
+
# Copy requirements
|
| 19 |
COPY requirements.txt .
|
| 20 |
|
| 21 |
+
# Install remaining dependencies (llama-cpp-python already installed)
|
| 22 |
+
RUN pip install --no-cache-dir -r requirements.txt --ignore-installed llama-cpp-python
|
| 23 |
|
| 24 |
# Copy application code
|
| 25 |
COPY . .
|
|
|
|
| 27 |
# Create models directory
|
| 28 |
RUN mkdir -p models
|
| 29 |
|
| 30 |
+
# Expose port 7860
|
| 31 |
EXPOSE 7860
|
| 32 |
|
| 33 |
+
# Run app
|
| 34 |
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860", "--timeout-keep-alive", "75"]
|