FROM python:3.10-slim # BUILD_TS=1780158810 # Configure environments ENV DEBIAN_FRONTEND=noninteractive ENV PYTHONUNBUFFERED=1 ENV PORT=7860 # Install system dependencies RUN apt-get update && apt-get install -y \ wget \ curl \ unzip \ && rm -rf /var/lib/apt/lists/* # Set up workdir WORKDIR /workspace # Download and install llama.cpp pre-compiled Ubuntu binary release RUN mkdir -p bin models bin_temp && \ curl -L -o llama.tar.gz https://github.com/ggml-org/llama.cpp/releases/download/b9279/llama-b9279-bin-ubuntu-x64.tar.gz && \ tar -xzf llama.tar.gz -C bin_temp --strip-components=1 && \ cp -r bin_temp/* bin/ && \ chmod +x bin/llama-server && \ rm -rf llama.tar.gz bin_temp # Copy requirements and install COPY requirements.txt requirements.txt RUN pip install --no-cache-dir -r requirements.txt # Copy all codebase COPY . . # Run download model script in build phase to embed the model in the image RUN python download_model.py # Create a non-root user for security (required by Hugging Face) RUN useradd -m -u 1000 user RUN chown -R user:user /workspace USER user # Set environment variables for the app ENV LLAMA_SERVER_PATH=/workspace/bin/llama-server ENV LD_LIBRARY_PATH=/workspace/bin:$LD_LIBRARY_PATH ENV LLAMA_PORT=8080 ENV FASTAPI_PORT=7860 ENV LLAMA_HOST=127.0.0.1 ENV LLAMA_THREADS=2 # Expose port EXPOSE 7860 # # ── Agentic LLM System ── # Install optional agent tool dependencies RUN pip install --no-cache-dir aiohttp>=3.9.0 2>/dev/null || true CMD ["python", "main.py"]