File size: 1,728 Bytes
f871fed
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
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"]