File size: 1,837 Bytes
3793f68
 
 
 
 
 
 
 
 
 
 
ade692a
 
a075c8a
ade692a
 
3793f68
 
 
a075c8a
e6a75b6
3793f68
 
e6a75b6
3793f68
 
 
 
 
ade692a
 
3793f68
 
 
 
 
 
 
 
 
 
be345f2
 
3793f68
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a66fc14
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
ENV UV_SYSTEM_PYTHON=1
ENV UV_BREAK_SYSTEM_PACKAGES=1
ENV TZ=Asia/Shanghai

COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/

# Install system dependencies
RUN apt-get update && apt-get install -y \
    curl tzdata \
    build-essential && \
    curl -sSf https://install.surrealdb.com | sh && \
    curl -fsS https://dotenvx.sh | sh && \
    rm -rf /var/lib/apt/lists/*

# Copy requirements.txt for dependency installation
COPY requirements.txt ./

# Install Python dependencies from requirements.txt
RUN uv pip install --no-cache-dir --upgrade pip && \
    uv 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
# requirements.txt

# 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 run_api.py start.sh api/ open_notebook/ commands/ migrations/ prompts/ ./
COPY . .

# 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"]