FROM python:3.10-slim # Install curl, tar, and libgomp1 (needed by pre-built llama-server C++ binary) RUN apt-get update && apt-get install -y curl tar libgomp1 && rm -rf /var/lib/apt/lists/* # Download native llama-server binary and libraries from official llama.cpp releases RUN curl -L -s https://github.com/ggml-org/llama.cpp/releases/download/b9964/llama-b9964-bin-ubuntu-x64.tar.gz -o /tmp/llama.tar.gz \ && mkdir -p /tmp/llama-extract \ && tar -xzf /tmp/llama.tar.gz -C /tmp/llama-extract \ && cp /tmp/llama-extract/llama-b9964/llama-server /usr/local/bin/llama-server \ && cp /tmp/llama-extract/llama-b9964/*.so* /usr/local/bin/ \ && cp /tmp/llama-extract/llama-b9964/*.so* /usr/local/lib/ \ && ldconfig \ && rm -rf /tmp/llama.tar.gz /tmp/llama-extract WORKDIR /code # Copy requirements and install python packages COPY ./requirements.txt /code/requirements.txt RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt RUN pip install --no-cache-dir llama-cpp-python[server] --extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cpu # Copy the application source code COPY . /code # Configure execution permissions RUN chmod +x /code/start.sh # Expose port 7860 as required by Hugging Face Spaces EXPOSE 7860 # Run startup script CMD ["/code/start.sh"]