Spaces:
Running
Running
File size: 1,333 Bytes
e44e7cc | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | # 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)"
|