Spaces:
Build error
Build error
using ollama
Browse files12345678910111213141516171819202122232425262728293031323334# Use a standard Python 3.12 imageFROM python:3.12-slimWORKDIR /app# --- 1. Install build-essential and cmake ---# This is necessary for compiling the C++ codeRUN apt-get update && apt-get install -y build-essential cmake# --- 2. Install Python Dependencies (with CPU-only build) ---# We set CMAKE_ARGS to disable CUDA, which makes the# build *much* faster and avoids the job timeout.ENV CMAKE_ARGS="-DLLAMA_CUDA=OFF"RUN pip install "llama-cpp-python[server]" huggingface_hub# --- 3. Model Download ---# This part is correct and remains the same.COPY download_model.py .ARG HF_TOKENRUN --mount=type=secret,id=HF_TOKEN \python download_model.py# --- 4. Server Runtime ---# This part is also correct and remains the same.EXPOSE 8000CMD [ \"python", \"-m", "llama_cpp.server", \"--model", "prem-1B-SQL.Q8_0.gguf", \"--n_gpu_layers", "0", \"--port", "8000", \"--host", "0.0.0.0", \"--api_key_env_var", "API_KEY" \]1234567891011121314151617181920212223242526# --- 1. Use the official Ollama pre-built image ---FROM ollama/ollama# --- 2. Install Python & dependencies for our download script ---# The base image is Debian, so we can use apt-getRUN apt-get update && apt-get install -y python3 python3-pipRUN pip install huggingface_hub# --- 3. Download the GGUF model ---WORKDIR /appCOPY download_model.py .ARG HF_TOKENRUN --mount=type=secret,id=HF_TOKEN \python3 download_model.py# --- 4. Create the Ollama "Modelfile" ---# This file tells Ollama to use our downloaded GGUFRUN echo "FROM /app/prem-1B-SQL.Q8_0.gguf" > /app/Modelfile# --- 5. Import the model into Ollama's registry ---# This makes the model available to serveRUN ollama create prem-sql-api -f /app/Modelfile# The base image's default command is "ollama serve",# which will automatically start the API server on port 11434.# It will also serve our newly created "prem-sql-api" model.
Dockerfile+20-28