FROM python:3.11-slim WORKDIR /app # Set PYTHONPATH to include /app ENV PYTHONPATH=/app # Set Hugging Face cache directories (writable in HF Spaces) ENV HF_HOME=/tmp ENV TRANSFORMERS_CACHE=/tmp ENV SENTENCE_TRANSFORMERS_HOME=/tmp # Install system dependencies RUN apt-get update && apt-get install -y \ curl \ build-essential \ && rm -rf /var/lib/apt/lists/* # Install SurrealDB RUN curl -sSf https://install.surrealdb.com | sh # Copy requirements.txt for dependency installation COPY requirements.txt ./ # Install Python dependencies from requirements.txt RUN pip install --no-cache-dir --upgrade pip && \ pip install --no-cache-dir -r requirements.txt # Explicitly ensure surreal-commands is installed (belt-and-suspenders approach) RUN pip install --no-cache-dir surreal-commands>=1.2.0 # Pre-download sentence-transformers model at build time # This will be cached in the Docker image RUN python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('all-MiniLM-L6-v2')" # Copy application code COPY api/ ./api/ COPY open_notebook/ ./open_notebook/ COPY commands/ ./commands/ COPY migrations/ ./migrations/ COPY prompts/ ./prompts/ COPY run_api.py ./ COPY start.sh ./ # Make start script executable RUN chmod +x start.sh # Set environment variables for SurrealDB connection ENV SURREAL_URL=ws://localhost:8000/rpc ENV SURREAL_ADDRESS=localhost ENV SURREAL_PORT=8000 ENV SURREAL_USER=root ENV SURREAL_PASS=root ENV SURREAL_NAMESPACE=open_notebook ENV SURREAL_DATABASE=main # Set API configuration for Hugging Face Spaces ENV API_HOST=0.0.0.0 ENV API_PORT=7860 ENV API_RELOAD=false # Expose Hugging Face Spaces port EXPOSE 7860 # Run the start script CMD ["./start.sh"]