Spaces:
Sleeping
Sleeping
Gokul commited on
Commit ·
f8ff2a0
1
Parent(s): 0306ba4
Switch to full Python image for binary support
Browse files- Dockerfile +20 -15
Dockerfile
CHANGED
|
@@ -1,6 +1,5 @@
|
|
| 1 |
-
# 1. Use
|
| 2 |
-
|
| 3 |
-
FROM python:3.10
|
| 4 |
|
| 5 |
# 2. Set working directory
|
| 6 |
WORKDIR /app
|
|
@@ -10,26 +9,32 @@ RUN useradd -m -u 1000 user
|
|
| 10 |
USER user
|
| 11 |
ENV PATH="/home/user/.local/bin:$PATH"
|
| 12 |
|
| 13 |
-
# 4.
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
-
# 5.
|
| 17 |
-
|
| 18 |
-
RUN pip install --no-cache-dir --upgrade pip setuptools wheel
|
| 19 |
|
| 20 |
-
#
|
|
|
|
|
|
|
|
|
|
| 21 |
RUN pip install --no-cache-dir torch --index-url https://download.pytorch.org/whl/cpu
|
| 22 |
-
|
| 23 |
-
# Install AI Engine Binary (Skips compilation entirely)
|
| 24 |
-
# The full python:3.10 image guarantees this will run.
|
| 25 |
RUN pip install --no-cache-dir llama-cpp-python \
|
| 26 |
--extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cpu
|
| 27 |
|
| 28 |
-
#
|
| 29 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 30 |
|
| 31 |
-
#
|
| 32 |
COPY --chown=user . .
|
| 33 |
|
| 34 |
-
#
|
| 35 |
CMD ["uvicorn", "api.index:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
| 1 |
+
# 1. Use Python 3.10 Slim (Fastest Download)
|
| 2 |
+
FROM python:3.10-slim
|
|
|
|
| 3 |
|
| 4 |
# 2. Set working directory
|
| 5 |
WORKDIR /app
|
|
|
|
| 9 |
USER user
|
| 10 |
ENV PATH="/home/user/.local/bin:$PATH"
|
| 11 |
|
| 12 |
+
# 4. Install ONLY the libraries needed for the AI Binary
|
| 13 |
+
# This takes 10 seconds and prevents the "Missing Compiler" crash
|
| 14 |
+
USER root
|
| 15 |
+
RUN apt-get update && apt-get install -y \
|
| 16 |
+
curl \
|
| 17 |
+
libopenblas-dev \
|
| 18 |
+
libgomp1 \
|
| 19 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 20 |
+
USER user
|
| 21 |
|
| 22 |
+
# 5. Copy requirements
|
| 23 |
+
COPY --chown=user requirements.txt .
|
|
|
|
| 24 |
|
| 25 |
+
# 6. ⚡ FORCE PRE-BUILT BINARY ⚡
|
| 26 |
+
# We install the AI Engine explicitly using the binary URL.
|
| 27 |
+
# Because we installed 'libopenblas' above, this will NOW WORK instantly.
|
| 28 |
+
RUN pip install --no-cache-dir --upgrade pip
|
| 29 |
RUN pip install --no-cache-dir torch --index-url https://download.pytorch.org/whl/cpu
|
|
|
|
|
|
|
|
|
|
| 30 |
RUN pip install --no-cache-dir llama-cpp-python \
|
| 31 |
--extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cpu
|
| 32 |
|
| 33 |
+
# 7. Install remaining requirements (Make sure llama-cpp-python is NOT in this file)
|
| 34 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 35 |
|
| 36 |
+
# 8. Copy App Code
|
| 37 |
COPY --chown=user . .
|
| 38 |
|
| 39 |
+
# 9. Start Server
|
| 40 |
CMD ["uvicorn", "api.index:app", "--host", "0.0.0.0", "--port", "7860"]
|