FROM python:3.12-slim ENV DEBIAN_FRONTEND=noninteractive ENV PYTHONUNBUFFERED=1 ENV PIP_NO_CACHE_DIR=1 WORKDIR /app RUN apt-get update && apt-get install -y --no-install-recommends \ git \ cmake \ build-essential \ curl \ ca-certificates \ libgomp1 \ && rm -rf /var/lib/apt/lists/* # Build llama.cpp for CPU. RUN git clone --depth 1 https://github.com/ggml-org/llama.cpp.git /tmp/llama.cpp \ && cmake -S /tmp/llama.cpp -B /tmp/llama.cpp/build \ -DGGML_NATIVE=OFF \ -DGGML_OPENMP=ON \ -DLLAMA_BUILD_SERVER=ON \ -DLLAMA_BUILD_TESTS=OFF \ -DLLAMA_BUILD_EXAMPLES=ON \ && cmake --build /tmp/llama.cpp/build \ --config Release \ --target llama-server \ -j2 \ && mkdir -p /opt/llama \ && cp /tmp/llama.cpp/build/bin/llama-server /opt/llama/llama-server \ && cp /tmp/llama.cpp/build/bin/*.so* /opt/llama/ 2>/dev/null || true \ && rm -rf /tmp/llama.cpp # Hugging Face downloader. RUN pip install --upgrade pip \ && pip install huggingface_hub COPY start.sh /app/start.sh RUN chmod +x /app/start.sh EXPOSE 7860 CMD ["/app/start.sh"]