ProfessorCEO commited on
Commit
0a2b15c
·
verified ·
1 Parent(s): 373a99c

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +18 -11
Dockerfile CHANGED
@@ -1,3 +1,4 @@
 
1
  FROM python:3.10-slim
2
 
3
  # 1. Setup User (Required by Spaces)
@@ -8,19 +9,25 @@ ENV HOME=/home/user \
8
 
9
  WORKDIR $HOME/app
10
 
11
- # 2. BYPASS BUILD: Install the Pre-Compiled Engine
12
- # We use a specific URL to get the "CPU Wheel" (Binary) directly.
13
- # This takes 30 seconds instead of 30 minutes.
14
- RUN pip install --no-cache-dir --upgrade pip && \
15
- pip install llama-cpp-python \
16
- --extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cpu
 
 
 
 
 
 
 
 
17
 
18
- # 3. Install the Rest
19
  COPY --chown=user requirements.txt requirements.txt
20
- # We remove llama-cpp-python from requirements so it doesn't try to rebuild it
21
- RUN sed -i '/llama-cpp-python/d' requirements.txt && \
22
- pip install --no-cache-dir -r requirements.txt
23
 
24
- # 4. Copy Code & Launch
25
  COPY --chown=user . .
26
  CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
+ # We use the full image, not slim, to ensure better compatibility
2
  FROM python:3.10-slim
3
 
4
  # 1. Setup User (Required by Spaces)
 
9
 
10
  WORKDIR $HOME/app
11
 
12
+ # 2. INSTALL THE FACTORY TOOLS (Mandatory)
13
+ # We need these. Without them, the build fails.
14
+ USER root
15
+ RUN apt-get update && apt-get install -y \
16
+ build-essential \
17
+ cmake \
18
+ git \
19
+ && rm -rf /var/lib/apt/lists/*
20
+ USER user
21
+
22
+ # 3. INSTALL WITH FALLBACK
23
+ # We try to download the binary. If that fails, we now have the tools (gcc) to build it.
24
+ # We set CMAKE_ARGS to make the build faster if it happens.
25
+ ENV CMAKE_ARGS="-DLLAMA_BLAS=OFF"
26
 
 
27
  COPY --chown=user requirements.txt requirements.txt
28
+ RUN pip install --no-cache-dir --upgrade pip && \
29
+ pip install --no-cache-dir -r requirements.txt --extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cpu
 
30
 
31
+ # 4. LAUNCH
32
  COPY --chown=user . .
33
  CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]