FROM python:3.10-slim ENV PYTHONDONTWRITEBYTECODE=1 \ PYTHONUNBUFFERED=1 \ PORT=7860 \ HF_HOME=/app/cache \ PATH="/home/user/.local/bin:${PATH}" WORKDIR /app # 1. Install runtime dependencies # Added 'libgomp1' here to fix the "libgomp.so.1" error RUN apt-get update && apt-get install -y \ curl \ libgomp1 \ && rm -rf /var/lib/apt/lists/* # 2. Create user and directories RUN useradd -m -u 1000 user RUN mkdir -p /app/cache /app/models /app/wheels && chown -R user:user /app # 3. Install pip RUN pip install --no-cache-dir --upgrade pip USER user # 4. Install the Local Wheel COPY --chown=user:user ./wheels /app/wheels RUN pip install --no-cache-dir /app/wheels/llama_cpp_python-*.whl # 5. Install other dependencies COPY --chown=user:user requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # 6. Copy ALL Application Code COPY --chown=user:user . . EXPOSE 7860 # 7. Start the app CMD ["bash", "-c", "while true; do curl -s https://xce009-ai-chat-api.hf.space/ping > /dev/null || true; sleep 300; done & python -m uvicorn main:app --host 0.0.0.0 --port 7860"]