FROM ubuntu:24.04 ENV DEBIAN_FRONTEND=noninteractive \ PYTHONUNBUFFERED=1 \ PIP_NO_CACHE_DIR=1 \ LLAMA_BIN_DIR=/opt/llama \ LD_LIBRARY_PATH=/opt/llama RUN apt-get update && apt-get install -y --no-install-recommends \ ca-certificates \ curl \ libgomp1 \ libssl3 \ python3 \ python3-pip \ && rm -rf /var/lib/apt/lists/* # Install official prebuilt llama.cpp server with dynamic x86_64 SIMD dispatch (AVX2 / AVX-512 / SapphireRapids / Zen4) RUN mkdir -p /opt/llama && \ curl -fsSL https://github.com/ggml-org/llama.cpp/releases/download/b12377/llama-b12377-bin-ubuntu-x64.tar.gz \ | tar -xz --strip-components=1 -C /opt/llama && \ chmod +x /opt/llama/llama-server RUN pip3 install --break-system-packages \ "fastapi>=0.115.0" \ "uvicorn[standard]>=0.32.0" \ "httpx>=0.27.0" \ "huggingface_hub>=0.30.0" # Hugging Face Spaces standard non-root UID 1000 user RUN useradd -m -u 1000 user USER user WORKDIR /home/user/app ENV HOME=/home/user \ MODEL_DIR=/home/user/app/models \ HF_HOME=/home/user/app/.hf_cache \ HF_XET_CACHE=/home/user/app/.hf_xet COPY --chown=user:user index.html style.css server.py /home/user/app/ EXPOSE 7860 CMD ["uvicorn", "server:app", "--host", "0.0.0.0", "--port", "7860", "--no-access-log"]