Spaces:
Build error
Build error
Update Dockerfile
Browse files- 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.
|
| 12 |
-
# We
|
| 13 |
-
|
| 14 |
-
RUN
|
| 15 |
-
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
-
# 3. Install the Rest
|
| 19 |
COPY --chown=user requirements.txt requirements.txt
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
pip install --no-cache-dir -r requirements.txt
|
| 23 |
|
| 24 |
-
# 4.
|
| 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"]
|