FROM python:3.11-slim RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential cmake git \ && rm -rf /var/lib/apt/lists/* RUN useradd -m -u 1000 user USER user ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH \ PYTHONUNBUFFERED=1 \ DATA_DIR=/home/user/app/data \ HF_HOME=/home/user/.cache/huggingface WORKDIR $HOME/app COPY --chown=user requirements.txt . RUN pip install --no-cache-dir --upgrade pip \ && ( pip install --no-cache-dir --prefer-binary llama-cpp-python \ --extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cpu \ || CMAKE_ARGS="-DGGML_NATIVE=OFF -DGGML_BLAS=OFF -DGGML_CUDA=OFF" \ FORCE_CMAKE=1 pip install --no-cache-dir llama-cpp-python ) \ && pip install --no-cache-dir -r requirements.txt COPY --chown=user . . RUN mkdir -p $DATA_DIR EXPOSE 7860 CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]