Spaces:
Build error
Build error
Update Dockerfile
Browse files- Dockerfile +40 -24
Dockerfile
CHANGED
|
@@ -1,29 +1,45 @@
|
|
| 1 |
-
|
|
|
|
| 2 |
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
RUN apt-get update && apt-get install -y \
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
curl \
|
| 6 |
-
|
|
|
|
|
|
|
| 7 |
|
| 8 |
-
#
|
| 9 |
-
WORKDIR /app
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
-
#
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
# Set env variable
|
| 15 |
-
ENV LLAMA_CPP_PATH=/app/build
|
| 16 |
-
|
| 17 |
-
# Expose a port if your llama-server does
|
| 18 |
-
EXPOSE 7860
|
| 19 |
-
|
| 20 |
-
# Run the server if it exists
|
| 21 |
-
CMD ["/bin/bash", "-c", "\
|
| 22 |
-
echo 'Listing $LLAMA_CPP_PATH/bin:' && \
|
| 23 |
-
ls -l $LLAMA_CPP_PATH/bin && \
|
| 24 |
-
if [ -x \"$LLAMA_CPP_PATH/bin/llama-server\" ]; then \
|
| 25 |
-
echo OK && \
|
| 26 |
-
$LLAMA_CPP_PATH/bin/llama-server -hf ggml-org/SmolVLM-500M-Instruct-GGUF; \
|
| 27 |
-
else \
|
| 28 |
-
echo 'llama-server not found'; exit 1; \
|
| 29 |
-
fi"]
|
|
|
|
| 1 |
+
# Hugging Face Spaces Dockerfile
|
| 2 |
+
FROM ubuntu:20.04
|
| 3 |
|
| 4 |
+
ENV DEBIAN_FRONTEND=noninteractive
|
| 5 |
+
ENV MODEL_URL=https://huggingface.co/ggml-org/SmolVLM-500M-Instruct-GGUF/resolve/main/SmolVLM-500M-Instruct-q4.gguf
|
| 6 |
+
|
| 7 |
+
# Create non-root user (required by Hugging Face)
|
| 8 |
+
RUN useradd -m -u 1000 user
|
| 9 |
+
USER user
|
| 10 |
+
ENV PATH="/home/user/.local/bin:$PATH"
|
| 11 |
+
WORKDIR /app
|
| 12 |
+
|
| 13 |
+
# Copy project files including llama.cpp
|
| 14 |
+
COPY --chown=user . /app
|
| 15 |
+
|
| 16 |
+
USER root
|
| 17 |
+
|
| 18 |
+
# Install required dependencies
|
| 19 |
RUN apt-get update && apt-get install -y \
|
| 20 |
+
git \
|
| 21 |
+
cmake \
|
| 22 |
+
build-essential \
|
| 23 |
+
g++ \
|
| 24 |
+
wget \
|
| 25 |
curl \
|
| 26 |
+
nodejs \
|
| 27 |
+
npm \
|
| 28 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 29 |
|
| 30 |
+
# Build the web UI (optional but standard)
|
| 31 |
+
WORKDIR /app/llama.cpp/examples/server/webui
|
| 32 |
+
RUN npm install
|
| 33 |
+
RUN npm run build
|
| 34 |
+
|
| 35 |
+
# Build llama-server
|
| 36 |
+
WORKDIR /app/llama.cpp
|
| 37 |
+
RUN cmake -B build -DBUILD_SHARED_LIBS=OFF
|
| 38 |
+
RUN cmake --build build --config Release -j 8
|
| 39 |
+
|
| 40 |
+
# Download the model
|
| 41 |
+
WORKDIR /app/llama.cpp/build/bin
|
| 42 |
+
RUN wget -nv -O model.gguf "$MODEL_URL"
|
| 43 |
|
| 44 |
+
# Run the llama-server
|
| 45 |
+
CMD ["./llama-server", "--host", "0.0.0.0", "--port", "8080", "-c", "2048", "-m", "model.gguf", "--cache-type-k", "q8_0"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|