# 1. Use the official image (Already has llama-cpp-python installed!) FROM ghcr.io/abetlen/llama-cpp-python:latest # 2. Reset the entrypoint # (The official image defaults to running the llama server; we disable this to run your app) ENTRYPOINT [] # 3. Set up User (Optional but good for HF Spaces) RUN useradd -m -u 1000 user USER user ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH WORKDIR $HOME/app # 4. Install Other Dependencies # Note: Do NOT include 'llama-cpp-python' in your requirements.txt COPY --chown=user ./requirements.txt requirements.txt RUN pip install --no-cache-dir --upgrade pip && \ pip install --no-cache-dir --upgrade -r requirements.txt # 5. Download NLTK Data ENV NLTK_DATA=$HOME/nltk_data RUN python3 -m nltk.downloader -d $NLTK_DATA punkt punkt_tab vader_lexicon # 6. Copy App COPY --chown=user ./app ./app # 7. Start CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]