Spaces:
Running
Running
| # Dockerfile for HuggingFace Spaces deployment | |
| FROM python:3.11-slim | |
| WORKDIR /app | |
| # Install system dependencies for sqlite | |
| RUN apt-get update && apt-get install -y \ | |
| build-essential \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Install pysqlite3 for HuggingFace Spaces | |
| RUN pip install pysqlite3-binary | |
| # Copy dependency files | |
| COPY pyproject.toml uv.lock* ./ | |
| # Install uv (Python package manager) | |
| RUN pip install uv | |
| # Install dependencies | |
| RUN uv pip install --system -r pyproject.toml || \ | |
| pip install -r requirements.txt || \ | |
| uv pip install --system gradio langchain langchain-community langchain-core chromadb sentence-transformers requests python-dotenv langchain-huggingface langchain-openai openai tiktoken fastapi uvicorn python-multipart pysqlite3-binary | |
| # Copy application files | |
| COPY . . | |
| # Create db directory if it doesn't exist | |
| RUN mkdir -p db multiple_docs game | |
| # Set environment variables (can be overridden in HF Spaces) | |
| ENV PORT=7860 | |
| ENV HF_TOKEN=${HF_TOKEN} | |
| ENV HF_MODEL_NAME=${HF_MODEL_NAME:-meta-llama/Llama-3.1-8B-Instruct:novita} | |
| # Expose port | |
| EXPOSE 7860 | |
| # Run FastAPI with uvicorn (HuggingFace Spaces uses port 7860) | |
| CMD python -c "import sys, os; sys.path.insert(0, '.'); from game_api import app; import uvicorn; port = int(os.getenv('PORT', 7860)); uvicorn.run(app, host='0.0.0.0', port=port)" | |